In MariaDB, MONTHNAME()
is a built-in date and time function that returns the name of the month name for a given date.
It accepts one argument, which is the date you want to extract the month name from.
Continue readingIn MariaDB, MONTHNAME()
is a built-in date and time function that returns the name of the month name for a given date.
It accepts one argument, which is the date you want to extract the month name from.
Continue readingMariaDB provides several ways to perform arithmetic on dates. This includes adding or subtracting a month (or many months) from a given date.
Here are 6 ways to add a month to a date in MariaDB.
Bonus update: I’ve now added a 7th way to add a month to a date at the end of this article. So I guess it’s now 7 ways to add a month to a date in MariaDB 🙂
Continue readingMariaDB has a lc_time_names
system variable that controls the language used by the DAYNAME()
, MONTHNAME()
and DATE_FORMAT()
date and time functions.
Here’s how to return the value of that variable.
Continue readingMariaDB supports a large list of locales that are used by functions such as DAYNAME()
, MONTHNAME()
and DATE_FORMAT()
.
While these locales are available to MariaDB, by default they’re not loaded into any of the system tables, so you can’t run a query to retrieve them.
However, MariaDB provides a plugin that does load these into a table. Once the plugin has been installed, you can query that table to return the locales available in MariaDB.
Continue readingBelow is a full list of date and time locales available in MariaDB.
Continue readingBelow is a full list of format specifiers that can be used in format strings with functions like DATE_FORMAT()
, STR_TO_DATE()
, and FROM_UNIXTIME()
in MariaDB.
MariaDB provides several ways to add a year or a certain number of years to a given date. For example, you might want to add 1 year, 10 years, 30 years, etc.
Here are 6 ways to add a year to a date in MariaDB.
Continue readingHere are some options for subtracting one or more minutes from a datetime expression in MariaDB.
Continue readingIf 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.
Continue readingIf 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.