In this guide, we will explain 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 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 :
- 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 TIMESTAMP function examples and explore how to use the TIMESTAMP function.
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'
Next Topic : Click Here
Pingback: MySQL: TIMEDIFF Function | Adglob Infosystem Pvt Ltd