@@ -762,6 +762,11 @@ select to_date('1947-04-15 00:00:00')
762762----
7637631947-04-15
764764
765+ query T
766+ select to_date('1941-03-15 00:00:00')
767+ ----
768+ 1941-03-15
769+
765770query T
766771select to_timestamp('1990-09-16 01:00:00');
767772----
@@ -852,6 +857,16 @@ set timezone='Asia/Shanghai';
852857statement ok
853858set enable_dst_hour_fix=1;
854859
860+ query T
861+ select to_monday(to_date('1919-04-13','%Y-%m-%d'));
862+ ----
863+ 1919-04-07
864+
865+ query T
866+ select to_year(to_date('1919-04-13','%Y-%m-%d'));
867+ ----
868+ 1919
869+
855870query T
856871SELECT DATE_ADD(month, 1, '1941-03-15 00:00:00'::timestamp);
857872----
@@ -882,13 +897,12 @@ SELECT substr(DATE_ADD(month, 1, now())::String, 11)=substr(now()::String, 11);
882897
883898# format: 11
884899query T
885- SELECT substr(DATE_ADD(month, 1, now())::String, 6, 2) =
886- CASE
887- WHEN substr(now()::String, 6, 2) = '12' THEN '01'
888- ELSE LPAD((substr(now()::String, 6, 2)::int + 1)::String, 2, '0')
889- END;
900+ select sum( ((m1 + number) % 12 = m2 or ((m1 + number) % 12 + m2 = 12))::Int ) from (
901+ select number, DATE_ADD(month, number, now()) as d, to_month(now()) as m1, to_month(d) as m2
902+ from numbers(1000)
903+ );
890904----
891- 1
905+ 1000
892906
893907# format: 2024
894908query T
@@ -947,13 +961,12 @@ SELECT substr(DATE_ADD(month, 1, now())::String, 11)=substr(now()::String, 11);
947961
948962# format: 11
949963query T
950- SELECT substr(DATE_ADD(month, 1, now())::String, 6, 2) =
951- CASE
952- WHEN substr(now()::String, 6, 2) = '12' THEN '01'
953- ELSE LPAD((substr(now()::String, 6, 2)::int + 1)::String, 2, '0')
954- END;
964+ select sum( ((m1 + number) % 12 = m2 or ((m1 + number) % 12 + m2 = 12))::Int ) from (
965+ select number, DATE_ADD(month, number, now()) as d, to_month(now()) as m1, to_month(d) as m2
966+ from numbers(1000)
967+ );
955968----
956- 1
969+ 1000
957970
958971# format: 2024
959972query T
@@ -1066,3 +1079,43 @@ query T
10661079select to_start_of_day('2024-11-14 11:54:33.667269');
10671080----
106810812024-11-14 00:00:00.000000
1082+
1083+
1084+ statement ok
1085+ set enable_strict_datetime_parser = 0;
1086+
1087+ query T
1088+ select to_date('2017-5-23 0:00:00')
1089+ ----
1090+ 2017-05-23
1091+
1092+ query T
1093+ select to_date('2018-1-22')
1094+ ----
1095+ 2018-01-22
1096+
1097+ query T
1098+ select to_date('2021/10/14')
1099+ ----
1100+ 2021-10-14
1101+
1102+ query T
1103+ select to_date('20201231')
1104+ ----
1105+ 2020-12-31
1106+
1107+ query T
1108+ select to_date('2017-3-16 0:00:00')
1109+ ----
1110+ 2017-03-16
1111+
1112+ query T
1113+ select to_timestamp('2017-02-03 14:55:08 ');
1114+ ----
1115+ 2017-02-03 14:55:08.000000
1116+
1117+ statement error 1006
1118+ select to_timestamp('1684275059752');
1119+
1120+ statement ok
1121+ unset enable_strict_datetime_parser;
0 commit comments