TIMESTAMP Function

Description

The TIMESTAMP function converts a DATE or TIMESTAMP type expression to DATETIME type.

If the DATE format string ('YYYY-MM-DD' or 'MM/DD/YYYY') or TIMESTAMP format string ('YYYY-MM-DD HH:MI:SS' or 'HH:MI:SS MM/DD/ YYYY') is specified as the first argument, the function returns it as DATETIME.

If the TIME format string ('HH:MI:SS') is specified as the second, the function adds it to the first argument and returns the result as a DATETIME type. If the second argument is not specified, 12:00:00.000 AM is specified by default.

Syntax

TIMESTAMP(date [,time])

Example

SELECT TIMESTAMP('2009-12-31'), TIMESTAMP('2009-12-31','12:00:00');

 timestamp('2009-12-31')        timestamp('2009-12-31', '12:00:00')

=====================================================================

  12:00:00.000 AM 12/31/2009     12:00:00.000 PM 12/31/2009

 

SELECT TIMESTAMP('2010-12-31 12:00:00','12:00:00');

 timestamp('2010-12-31 12:00:00', '12:00:00')

===============================================

  12:00:00.000 AM 01/01/2011

 

SELECT TIMESTAMP('13:10:30 12/25/2008');

 timestamp('13:10:30 12/25/2008')

===================================

  01:10:30.000 PM 12/25/2008