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 readingIn 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 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.
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.
You can use the T-SQL code below to convert a month number to its corresponding name in SQL Server.
This is for times where you don’t actually have the full date – when all you have is the month number. If you do have the date, then here’s how to get the month name from a date.
Continue readingIn SQL Server, you can use the FORMAT()
function to return the short day name from a date. FORMAT()
is a T-SQL function that enables you to format dates and numbers to a specified format.
This function returns its result as a string. Specifically, it returns it as either a nvarchar or null as the case may be.
Continue readingWhenever 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
.
This article presents 5 ways to return the milliseconds portion from a Date object in MongoDB.
Continue readingThis article presents 5 ways to return the seconds portion from a Date object in MongoDB.
Continue readingThis article presents 5 ways to return the minutes portion from a Date object in MongoDB.
Continue reading