Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.2.1 |  CUBRID 8.3.0 |  CUBRID 8.3.1 |  CUBRID 8.4.0 |  CUBRID 8.4.1 |  CUBRID 8.4.3 |  CUBRID 9.0.0 | 

TO_TIME Function


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).

When the format argument is assigned, the string is interpreted according to the specified language. For example, when a language is "de_DE" and string is "10:23:00 Nachm.", and format is "HH/MI/SS/AM, it is interpreted as 10:23:00 PM. In this case, the language is set by date_lang_string_literal argument. If date_lang_string_literal argument is not set, the language used is the language specified in the intl_number_lang system parameter and when the value of intl_number_lang is not set, the language specified in the CUBRID_LANG environment variable is used. When the format parameter specified does not correspond to the given string, an error is returned.

If the format argument is omitted, string is interpreted according to default output format set by intl_date_lang or CUBRID_LANG (see Default Output of Number for Each Language of TO_CHAR Function (date_time). For example, when a language is "de_DE", the default format of the TIME type is "HH24:MI:SS".


TO_TIME(string [,format [,date_lang_string_literal]]):


string :

character strings



format :

character strings (see the table, Date/Time Format 1)



date_lang_string_literal : (see the table, date_lang_string_literal)

• 'en_US'

• 'de_DE'

• 'es_ES'

• 'fr_FR'

• 'it_IT'

• 'ja_JP'

• 'km_KH'

• 'ko_KR'

• 'tr_TR'

• 'vi_VN'

• 'zh_CN'

  • string: Specifies an expression that returns character string. If the value is NULL, NULL is returned.
  • format: Specifies a format of return value to be converted as TIME type. See the "Default Date-Time Format" table of TO_CHAR Function (date_time). If the value is NULL, NULL is returned.
  • date_lang_string_literal: Specifies the language for the input value to be applied.

Note The CUBRID_DATE_LANG environment used in earlier version of CUBRID 9.0 is no longer supported.


The following example shows execution of the database by setting the environment variable CUBRID_LANG to "en_US".

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


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



  01:10:30 PM



 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')


  01:10:30 PM


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


ERROR: Conversion error in date format.

The following example shows the case when the system parameter intl_date_lang is "de_DE".

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



  01:10:30 PM


SELECT TO_TIME('10:23:00 Nachm.', 'HH:MI:SS AM');

   to_time('10:23:00 Nachm.', 'HH:MI:SS AM')


  10:23:00 PM


When only the language is set to "en_US" (the initial value of CUBRID_LANG at installation of CUBRID) in the locale of the CUBRID_LANG environment variable and charset after "." is omitted, the charset is set to ISO-8859-1 (.iso88591).

When the charset is ISO-8859-1, the language that can be changed in TO_TIME function is "ko_KR" and "tr_TR" except "en_US". If the charset is UTF-8, it can be changed to any language supported by CUBRID. For details, see Remark in the TO_CHAR Function (date_time).