to_tera_timestamp
指定されたフォーマットに従って日付または時刻の文字列を解析し、その文字列を DATETIME 値に変換します。
構文
DATETIME to_tera_timestamp(VARCHAR str, VARCHAR format)
パラメータ
-
str
: 変換する時刻表現。VARCHAR 型である必要があります。 -
format
:str
の時刻フォーマット指定子。入力文字列を解析し変換するために使用されます。format
はstring
と一致しなければなりません。それ以外の場合は、NULL が返されます。format
が無効な場合は、エラーが返されます。次の表はフォーマット要素を説明しています。
要素 説明 [ \r \n \t - / , . ;] 変換時に無視される句読点文字 dd 月の日 (1 - 31) hh 日の時間 (1 - 12) hh24 日の時間 (0 - 23) mi 分 (0 - 59) mm 月 (01 - 12) ss 秒 (0 - 59) yyyy 4 桁の年 yy 2 桁の年 am 午前午後の指標 pm 午前午後の指標
例
select to_tera_timestamp("1988/04/08","yyyy/mm/dd");
+-----------------------------------------------+
| to_tera_timestamp('1988/04/08', 'yyyy/mm/dd') |
+-----------------------------------------------+
| 1988-04-08 00:00:00 |
+-----------------------------------------------+
select to_tera_timestamp("04-08-1988","mm-dd-yyyy");
+-----------------------------------------------+
| to_tera_timestamp('04-08-1988', 'mm-dd-yyyy') |
+-----------------------------------------------+
| 1988-04-08 00:00:00 |
+-----------------------------------------------+
select to_tera_timestamp("04.1988,08","mm.yyyy,dd");
+-----------------------------------------------+
| to_tera_timestamp('04.1988,08', 'mm.yyyy,dd') |
+-----------------------------------------------+
| 1988-04-08 00:00:00 |
+-----------------------------------------------+
select to_tera_timestamp("1988/04/08 2","yyyy/mm/dd hh");
+----------------------------------------------------+
| to_tera_timestamp('1988/04/08 2', 'yyyy/mm/dd hh') |
+----------------------------------------------------+
| 1988-04-08 02:00:00 |
+----------------------------------------------------+
select to_tera_timestamp("1988/04/08 14","yyyy/mm/dd hh24");
+-------------------------------------------------------+
| to_tera_timestamp('1988/04/08 14', 'yyyy/mm/dd hh24') |
+-------------------------------------------------------+
| 1988-04-08 14:00:00 |
+-------------------------------------------------------+
select to_tera_timestamp("1988/04/08 14:15","yyyy/mm/dd hh24:mi");
+-------------------------------------------------------------+
| to_tera_timestamp('1988/04/08 14:15', 'yyyy/mm/dd hh24:mi') |
+-------------------------------------------------------------+
| 1988-04-08 14:15:00 |
+-------------------------------------------------------------+
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 |
+----------------------------------------------------------------+
select to_tera_timestamp("1988/04/08 02 am:3:4","yyyy/mm/dd hh am:mi:ss");
+---------------------------------------------------------------------+
| to_tera_timestamp('1988/04/08 02 am:3:4', 'yyyy/mm/dd hh am:mi:ss') |
+---------------------------------------------------------------------+
| 1988-04-08 02:03:04 |
+---------------------------------------------------------------------+
キーワード
TO_TERA_TIMESTAMP