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

MySQL CURDATE Function

Example

Return the current date:

SELECT CURDATE();

Definition and Usage

The CURDATE() function returns the current date.

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

Continue reading MySQL CURDATE Function

MySQL ADDTIME Function

Example

Add 2 seconds to a time and return the datetime:

SELECT ADDTIME("2017-06-15 09:34:21", "2");

Definition and Usage

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

MySQL ADDDATE Function

Example

Add 10 days to a date and return the date:

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

Definition and Usage

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

MySQL TRUNCATE Function

Example

Return a number truncated to 2 decimal places:

SELECT TRUNCATE(135.375, 2);

Definition and Usage

The TRUNCATE() function truncates a number to the specified number of decimal places.

Continue reading MySQL TRUNCATE Function