Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

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

TIME_FORMAT Function

Description

The TIME_FORMAT function converts the value of strings with TIME format ('HH-MI-SS) or that of date/time data type (DATE, TIMESTAMP, DATETIME) to specified date/time format and then return the value with the VARCHAR data type.

When the format argument is assigned, the time is output according to the specified language. At this time, the language specified to the intl_date_lang system parameter is applied. For example, when the language is set to "de_DE" and the format is "%h:%i:%s %p", "08:46:53 PM" is output as "08:46:53 Nachm.". When the intl_date_lang value is not set, the language applied to the CUBRID_LANG environment variable is applied. When the format argument specified does not correspond to the given string, an error is returned.

Syntax

TIME_FORMAT(time, format)

  • time: A value of string with TIME (HH:MI:SS) or that of date/time data type ((DATE, TIMESTAMP, DATETIME) an be specified.
  • format: Specifies the output format. Use a string that contains ‘%’ as a specifier. See the table, Date/Time Format 2 of DATE_FORMAT Function.
Example

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

SELECT TIME_FORMAT('22:23:00', '%H %i %s');

 time_format('22:23:00', '%H %i %s')

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

  '22 23 00'

 

SELECT TIME_FORMAT('23:59:00', '%H %h %i %s %f');

 time_format('23:59:00', '%H %h %i %s %f')

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

  '23 11 59 00 000'

 

SELECT SYSTIME, TIME_FORMAT(SYSTIME, '%p');

 SYS_TIME     time_format( SYS_TIME , '%p')

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

  08:46:53 PM  'PM'

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

csql> ;se intl_date_lang="de_DE"

SELECT SYSTIME, TIME_FORMAT(SYSTIME, '%p');

 

   SYS_TIME     time_format( SYS_TIME , '%p')

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

  08:46:53 PM  'Nachm.'

Remark

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_DATE function is "ko_KR" and "tr_TR" except "en_US". If the charset is UTF-8, it can be changed to any language suppored by CUBRID. For details, see Remark in the TO_CHAR Function (date_time).