Example
Format a date:
SELECT DATE_FORMAT("2017-06-15", "%Y");
Definition and Usage
The DATE_FORMAT() function formats a date as specified. Continue reading MySQL DATE_FORMAT 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).
Return the current date:
SELECT CURDATE();
The CURDATE() function returns the current date.
Note: The date is returned as “YYYY-MM-DD” (string) or as YYYYMMDD (numeric).
Add 2 seconds to a time and return the datetime:
SELECT ADDTIME("2017-06-15 09:34:21", "2");
The ADDTIME() function adds a time interval to a time/datetime and then returns the time/datetime. Continue reading MySQL ADDTIME Function