@@ -762,6 +762,11 @@ select to_date('1947-04-15 00:00:00')
762
762
----
763
763
1947-04-15
764
764
765
+ query T
766
+ select to_date('1941-03-15 00:00:00')
767
+ ----
768
+ 1941-03-15
769
+
765
770
query T
766
771
select to_timestamp('1990-09-16 01:00:00');
767
772
----
@@ -852,6 +857,16 @@ set timezone='Asia/Shanghai';
852
857
statement ok
853
858
set enable_dst_hour_fix=1;
854
859
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
+
855
870
query T
856
871
SELECT DATE_ADD(month, 1, '1941-03-15 00:00:00'::timestamp);
857
872
----
@@ -882,13 +897,12 @@ SELECT substr(DATE_ADD(month, 1, now())::String, 11)=substr(now()::String, 11);
882
897
883
898
# format: 11
884
899
query 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
+ );
890
904
----
891
- 1
905
+ 1000
892
906
893
907
# format: 2024
894
908
query T
@@ -947,13 +961,12 @@ SELECT substr(DATE_ADD(month, 1, now())::String, 11)=substr(now()::String, 11);
947
961
948
962
# format: 11
949
963
query 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
+ );
955
968
----
956
- 1
969
+ 1000
957
970
958
971
# format: 2024
959
972
query T
@@ -1066,3 +1079,43 @@ query T
1066
1079
select to_start_of_day('2024-11-14 11:54:33.667269');
1067
1080
----
1068
1081
2024-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