to_tera_timestamp

Description

Converts the specified VARCHAR value into a DATETIME value in the specified format.

Syntax

DATETIME to_tera_timestamp(VARCHAR str, VARCHAR format)

Parameters

  • str: the time expression you want to convert. It must be of the VARCHAR type.

  • format: the format of the DATETIME value to be returned.

    The following table describes the format elements.

    ElementDescription
    [ \r \n \t - / , . ;]Punctuation characters are ignored.
    ddDay of the month. Valid values: 1 - 31.
    hhHour of the day. Valid values: 1 - 12.
    hh24Hour of the day. Valid values: 0 - 23.
    miMinute. Valid values: 0 - 59.
    mmMonth. Valid values: 01 - 12.
    ssSecond. Valid values: 0 - 59.
    yyyy4-digit year.
    yy2-digit year.
    amMeridian indicator.
    pmMeridian indicator.

Examples

The following example converts the VARCHAR value 1988/04/08 2:3:4 into a DATETIME value in yyyy/mm/dd hh24:mi:ss format.

MySQL > select to_tera_timestamp("1988/04/08 2:3:4","yyyy/mm/dd hh24:mi:ss");
+-----------------------------------------------------------+
| to_tera_timestamp('1988/04/08 2:3:4', 'yyyy/mm/dd hh24:mi:ss') |
+-----------------------------------------------------------+
| 1988-04-08 02:03:04                                       |
+-----------------------------------------------------------+

Keywords

TO_TERA_TIMESTAMP