MySQL: TIMESTAMP Function
This MySQL tutorial explains how to use the MySQL TIMESTAMP function with syntax and examples.
Description
The MySQL TIMESTAMP function converts an expression to a datetime value and if specified adds an optional time interval to the value.
Syntax
The syntax for the TIMESTAMP function in MySQL is:
TIMESTAMP( expression, [ interval ] )
Parameters or Arguments
- expression
- A date or datetime value that will be converted.
- interval
- Optional. It is a time value to add to the expression.
Note
- The TIMESTAMP function will return a datetime value.
Applies To
The TIMESTAMP function can be used in the following versions of MySQL:
- MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1.1
Example
Let's look at some MySQL TIMESTAMP function examples and explore how to use the TIMESTAMP function in MySQL.
For example:
mysql> SELECT TIMESTAMP('2014-02-18'); Result: '2014-02-18 00:00:00' mysql> SELECT TIMESTAMP('2014-02-18', '07:32:00'); Result: '2014-02-18 07:32:00' mysql> SELECT TIMESTAMP('2014-02-18 10:05:00', '02:03:04'); Result: '2014-02-18 12:08:04'
Advertisements