Below are 4 functions that enable you to return the year from a date in MariaDB. Three functions return just the year, and one returns both the year and week.
Continue readingTag: date format
3 Ways to Get the Day Name from a Date in MariaDB
Below are three approaches you can use to get the day name from a date in MariaDB.
Two of these approaches return the full day name, and one returns the short day name.
Continue reading11 Functions to Get the Day, Month, and Year from a Date in MariaDB
MariaDB includes many functions for working with dates. Some of these extract certain parts from such dates and return them as a string or integer.
Below are 11 functions that you can use to return various date parts in MariaDB.
Continue reading3 Ways to Convert a Date to a String in MongoDB
MongoDB has a Date BSON type that allows you to store dates as dates.
You can also store dates as strings, if that’s what you need.
Taking it a step further, you can also convert a Date to a string.
This article presents three ways to convert a Date to a string in MongoDB.
Continue readingConvert a Month Name to the Month Number in SQL Server (T-SQL)
In SQL Server, you can use the MONTH()
function to convert a month name to its corresponding number.
3 Ways to Get the Month Name from a Date in MariaDB
Here are three ways to return the month name from a date in MariaDB.
Continue readingHow MONTHNAME() Works in MariaDB
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 readingHow DATE_FORMAT() Works in MariaDB
In MariaDB, DATE_FORMAT()
is a built-in date and time function that formats a date according to the given format string.
It requires two arguments; the date and the format string. It also accepts an optional third argument that allows you to specify the locale.
Continue readingMariaDB Date Format Strings
Below 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.
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.