In MySQL, you can use the GET_FORMAT()
function to return a format string for the provided arguments. This can be useful when you need to provide a format string to another function, such as DATE_FORMAT()
or STR_TO_DATE()
.
FROM_UNIXTIME() Examples – MySQL
The MySQL FROM_UNIXTIME()
function enables you to return a date representation of a Unix timestamp.
More specifically, it returns the Unix timestamp as a value in ‘YYYY-MM-DD HH:MM:SS’ or YYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context.
UNIX_TIMESTAMP() Examples – MySQL
In MySQL, you can use the UNIX_TIMESTAMP()
function to return a Unix timestamp. A Unix timestamp is the number of seconds that have elapsed since ‘1970-01-01 00:00:00’ UTC.
You can use this function to return a Unix timestamp based on the current date/time or another specified date/time.
TO_DAYS() Examples – MySQL
In MySQL, you can use the TO_DAYS()
function to find out how many days have passed since day 0 for a particular date. For example, you can pass today’s date to this function, and it will return how many days it’s been since day 0.
This article contains examples to demonstrate.
FROM_DAYS() Examples – MySQL
In MySQL, the FROM_DAYS()
function returns a date value based on the number of days provided as an argument.
This article contains examples to demonstrate.
EXTRACT() Examples – MySQL
In MySQL, you can use the EXTRACT()
function to extract parts from a date. For example, you can extract the year part, the month part, or the day part, etc. You can also extract parts from the time component, such as minutes, seconds, microseconds, etc.
This article contains examples to demonstrate.
DAYOFYEAR() Examples – MySQL
When running queries in MySQL, you can use the DAYOFYEAR()
function to return the day of the year from a date.
This function accepts one argument, and it returns a value between 1 and 366, depending on which day of the year the day part of the argument represents.
DAYOFWEEK() Examples – MySQL
You can use the DAYOFWEEK()
function in MySQL to return the day of the week from a date.
In this context, a return value of 1 corresponds to Sunday, 2 corresponds to Monday, etc.
This article contains examples to demonstrate.
DAYNAME() Examples – MySQL
You can use the DAYNAME()
function in MySQL to return the weekday name from a date.
By “weekday name”, I mean a value like Monday or Sunday. For example, if you provide a date of 2018-01-07, the DAYNAME()
function will return Sunday.
DAY() Examples – MySQL
In MySQL, the DAY()
function is a synonym for the DAYOFMONTH()
function. It’s used to return the day of the month from a date.
In this context the “day of the month” is a value between 1 and 31, or 0 for dates with a zero day part. For example, if you provide a date of 2020-05-03, the DAY()
function will return 3.