MySQL TIMESTAMP() Function
In MySQL, the TIMESTAMP() function sum all arguments and return the result as a datetime value.
TIMESTAMP() Syntax
Here is the syntax of MySQL TIMESTAMP() function:
TIMESTAMP(date_or_datetime)
or
TIMESTAMP(date_or_datetime, time)
Parameters
date_or_datetime- Required. A date or datetime expression. Format:
YYYY-MM-DDorYYYY-MM-DD HH:MM:SS time- Optional. A time value. Format:
HH:MM:SS.
Return value
The TIMESTAMP(date_or_datetime) function will return date_or_datetime as a datetime value, and the TIMESTAMP(date_or_datetime, time) sum date_or_datetime and time as a datetime value.
The TIMESTAMP() function will return NULL if any parameter is NULL.
TIMESTAMP() Examples
Here are some examples of the TIMESTAMP() function.
Example 1
SELECT TIMESTAMP('2022-02-28');
+-------------------------+
| TIMESTAMP('2022-02-28') |
+-------------------------+
| 2022-02-28 00:00:00 |
+-------------------------+Example 2
SELECT TIMESTAMP('2022-02-28', '10:10:10');
+-------------------------------------+
| TIMESTAMP('2022-02-28', '10:10:10') |
+-------------------------------------+
| 2022-02-28 10:10:10 |
+-------------------------------------+Example 3
SELECT TIMESTAMP('2022-02-28 12:00:00', '12:00:00');
+----------------------------------------------+
| TIMESTAMP('2022-02-28 12:00:00', '12:00:00') |
+----------------------------------------------+
| 2022-03-01 00:00:00 |
+----------------------------------------------+