TIME_TO_SEC Function

Description

The TIME_TO_SEC function returns the seconds in the range of 0 to 86,399 from specified argument. You can specify the TIME, TIMESTAMP, or DATETIME type; the value is returned in INTEGER type.

Syntax

TIME_TO_SEC(time)

Example

SELECT TIME_TO_SEC('23:00:00');

   time_to_sec('23:00:00')

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

                     82800

 

SELECT TIME_TO_SEC('2010-10-04 23:00:00');

   time_to_sec('2010-10-04 23:00:00')

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

                                82800

 

 SELECT TIME_TO_SEC('2010-10-04 23:00:00.1234');

   time_to_sec('2010-10-04 23:00:00.1234')

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

                                     82800

 

SELECT TIME_TO_SEC('2010-01-01');

 

ERROR: Conversion error in time format.