Example
Extract the month from a date:
SELECT EXTRACT(MONTH FROM "2017-06-15");
Definition and Usage
The EXTRACT() function extracts a part from a given date. Continue reading MySQL EXTRACT Function
Extract the month from a date:
SELECT EXTRACT(MONTH FROM "2017-06-15");
The EXTRACT() function extracts a part from a given date. Continue reading MySQL EXTRACT Function
Return the day of the year for a date:
SELECT DAYOFYEAR("2017-06-15");
The DAYOFYEAR() function returns the day of the year for a given date (a number from 1 to 366). Continue reading MySQL DAYOFYEAR Function
Return the weekday index for a date:
SELECT DAYOFWEEK("2017-06-15");
The DAYOFWEEK() function returns the weekday index for a given date (a number from 1 to 7).
Note: 1=Sunday, 2=Monday, 3=Tuesday, 4=Wednesday, 5=Thursday, 6=Friday, 7=Saturday. Continue reading MySQL DAYOFWEEK Function
Return the day of the month for a date:
SELECT DAYOFMONTH("2017-06-15");
The DAYOFMONTH() function returns the day of the month for a given date (a number from 1 to 31).
Return the weekday name for a date:
SELECT DAYNAME("2017-06-15");
The DAYNAME() function returns the weekday name for a given date. Continue reading MySQL DAYNAME Function
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