to_tera_date

Description

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

Syntax

DATE to_tera_date(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 date and time 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 into a date in yyyy/mm/dd format:

MySQL > select to_tera_date("1988/04/08","yyyy/mm/dd");
+------------------------------------------+
| to_tera_date('1988/04/08', 'yyyy/mm/dd') |
+------------------------------------------+
| 1988-04-08                               |
+------------------------------------------+

Keywords

TO_TERA_DATE