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

MySQL DATE Function

Example

Extract the date part:

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

Definition and Usage

The DATE() function extracts the date part from a datetime expression.

Syntax

DATE(expression)

Continue reading MySQL DATE Function

MySQL CURTIME Function

Example

Return current time:

SELECT CURTIME();

Definition and Usage

The CURTIME() function returns the current time.

Note: The time is returned as “HH-MM-SS” (string) or as HHMMSS.uuuuuu (numeric).

Continue reading MySQL CURTIME Function

MySQL CURRENT_TIMESTAMP Function

Example

Return the current date and time:

SELECT CURRENT_TIMESTAMP();

Definition and Usage

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

MySQL CURRENT_TIME Function

Example

Return current time:

SELECT CURRENT_TIME();

Definition and Usage

The CURRENT_TIME() function returns the current time.

Note: The time is returned as “HH-MM-SS” (string) or as HHMMSS.uuuuuu (numeric).

Continue reading MySQL CURRENT_TIME Function

MySQL CURRENT_DATE Function

Example

Return the current date:

SELECT CURRENT_DATE();

Definition and Usage

The CURRENT_DATE() function returns the current date.

Note: The date is returned as “YYYY-MM-DD” (string) or as YYYYMMDD (numeric).

Continue reading MySQL CURRENT_DATE Function