Example
Return the day of the month for a date:
SELECT DAY("2017-06-15");
Definition and Usage
The DAY() function returns the day of the month for a given date (a number from 1 to 31).
Return the day of the month for a date:
SELECT DAY("2017-06-15");
The DAY() function returns the day of the month for a given date (a number from 1 to 31).
Subtract 10 days from a date and return the date:
SELECT DATE_SUB("2017-06-15", INTERVAL 10 DAY);
The DATE_SUB() function subtracts a time/date interval from a date and then returns the date. Continue reading MySQL DATE_SUB Function
Format a date:
SELECT DATE_FORMAT("2017-06-15", "%Y");
The DATE_FORMAT() function formats a date as specified. Continue reading MySQL DATE_FORMAT Function
Add 10 days to a date and return the date:
SELECT DATE_ADD("2017-06-15", INTERVAL 10 DAY);
The DATE_ADD() function adds a time/date interval to a date and then returns the date. Continue reading MySQL DATE_ADD Function
Return the number of days between two date values:
SELECT DATEDIFF("2017-06-25", "2017-06-15");
The DATEDIFF() function returns the number of days between two date values. Continue reading MySQL DATEDIFF Function
Extract the date part:
SELECT DATE("2017-06-15");
The DATE() function extracts the date part from a datetime expression.
DATE(expression)
Return current time:
SELECT CURTIME();
The CURTIME() function returns the current time.
Note: The time is returned as “HH-MM-SS” (string) or as HHMMSS.uuuuuu (numeric).
Return the current date and time:
SELECT CURRENT_TIMESTAMP();
The CURRENT_TIMESTAMP() function returns the current date and time.
Note: The date and time is returned as “YYYY-MM-DD HH-MM-SS” (string) or as YYYYMMDDHHMMSS.uuuuuu (numeric). Continue reading MySQL CURRENT_TIMESTAMP Function
Return current time:
SELECT CURRENT_TIME();
The CURRENT_TIME() function returns the current time.
Note: The time is returned as “HH-MM-SS” (string) or as HHMMSS.uuuuuu (numeric).
Return the current date:
SELECT CURRENT_DATE();
The CURRENT_DATE() function returns the current date.
Note: The date is returned as “YYYY-MM-DD” (string) or as YYYYMMDD (numeric).