How to Set Up Named Time Zones in MariaDB

If you want to use named time zones in MariaDB, you’ll need to make sure they’ve been configured.

By “named time zones”, I mean being able to use strings like America/Los_Angeles instead of −08:00 or −07:00 when specifying the time zone. For example, when using the CONVERT_TZ() function.

Here’s how to configure named time zones in MariaDB.

Read more

How to Format the Date in MongoDB

If you have documents that store dates as Date objects, but you want to return them in a different format, you can use the $dateToString aggregate pipeline operator.

For example, you might want a date to be returned in mm/dd/yyyy format instead of the long ISODate() format that includes minutes, seconds, milliseconds, etc

The $dateToString operator converts the Date object to a string, and optionally allows you to specify a format for the resulting output.

Read more

8 Ways to Add Days to a Date in MariaDB

MariaDB provides several ways to add a certain number of days to a given date. For example, you might want to add 10 days to a date, or 30 days, or even just 1 day. Fortunately, MariaDB makes this easy.

Here are 8 ways to add a number of days to a given date in MariaDB.

Read more

Change the Date Format For the Current Session in SQL Server

Whenever you connect to SQL Server, a bunch of default settings are applied to your session. These include the language and the date format settings.

The date format is normally determined by your default language. For example, if your default language is us_english, then the default date format will probably be mdy, and the first day of the week will be day 7 (Sunday).

If you change your language, you the date format will implicitly be updated accordingly.

However, you still have the option of changing the date format without changing the language. To do this, you can use SET DATEFORMAT.

Read more