MySQL EXTRACT Function

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

MySQL DAYOFYEAR Function

Example

Return the day of the year for a date:

SELECT DAYOFYEAR("2017-06-15");

Definition and Usage

The DAYOFYEAR() function returns the day of the year for a given date (a number from 1 to 366). Continue reading MySQL DAYOFYEAR Function

MySQL DAYOFWEEK Function

Example

Return the weekday index for a date:

SELECT DAYOFWEEK("2017-06-15");

Definition and Usage

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

MySQL DAYOFMONTH Function

Example

Return the day of the month for a date:

SELECT DAYOFMONTH("2017-06-15");

Definition and Usage

The DAYOFMONTH() function returns the day of the month for a given date (a number from 1 to 31).

Continue reading MySQL DAYOFMONTH Function

MySQL DAYNAME Function

Example

Return the weekday name for a date:

SELECT DAYNAME("2017-06-15");

Definition and Usage

The DAYNAME() function returns the weekday name for a given date. Continue reading MySQL DAYNAME Function

MySQL DAY Function

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).

Continue reading MySQL DAY Function

MySQL DATE_SUB Function

Example

Subtract 10 days from a date and return the date:

SELECT DATE_SUB("2017-06-15", INTERVAL 10 DAY);

Definition and Usage

The DATE_SUB() function subtracts a time/date interval from a date and then returns the date. Continue reading MySQL DATE_SUB Function

MySQL DATE_FORMAT Function

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

MySQL DATE_ADD Function

Example

Add 10 days to a date and return the date:

SELECT DATE_ADD("2017-06-15", INTERVAL 10 DAY);

Definition and Usage

The DATE_ADD() function adds a time/date interval to a date and then returns the date. Continue reading MySQL DATE_ADD Function

MySQL DATEDIFF Function

Example

Return the number of days between two date values:

SELECT DATEDIFF("2017-06-25", "2017-06-15");

Definition and Usage

The DATEDIFF() function returns the number of days between two date values. Continue reading MySQL DATEDIFF Function