TO_TIME Function

Description

The TO_TIME function interprets a character string based on the time format given as an argument, converts it to a TIME type value, and returns it. For the format, see TO_CHAR Function (date_time). If a format is not specified, the "HH:MI:SS" format is applied by default.

Syntax

TO_TIME(string_argument[,format_argument [,date_lang_string_literal]]):

 

string_argument :

character strings

NULL

 

format_argument :

character strings (see Date/Time Format 1)

NULL

 

date_lang_string_literal : (see date_lang_string_literal)

• 'en_US'

• 'ko_KR'

Example

--selecting a time type value casted from a string in the specified format

 

SELECT TO_TIME ('13:10:30');

 to_time('13:10:30')=============================================

  01:10:30 PM

 

SELECT TO_TIME('HOUR: 13 MINUTE: 10 SECOND: 30', '"HOUR:" HH24 "MINUTE:" MI "SECOND:" SS');

 to_time('HOUR: 13 MINUTE: 10 SECOND: 30', '"HOUR:" HH24 "MINUTE:" MI "SECOND:" SS', 'en_US')=============================================

  01:10:30 PM

 

SELECT TO_TIME ('13:10:30', 'HH24:MI:SS');

 to_time('13:10:30', 'HH24:MI:SS', 'en_US')

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

  01:10:30 PM

 

SELECT TO_TIME ('13:10:30', 'HH12:MI:SS');

 

ERROR: Conversion error in date format.