1
drop table if exists t1,t2,t3;
2
set time_zone="+03:00";
3
select from_days(to_days("960101")),to_days(960201)-to_days("19960101"),to_days(date_add(curdate(), interval 1 day))-to_days(curdate()),weekday("1997-11-29");
4
from_days(to_days("960101")) to_days(960201)-to_days("19960101") to_days(date_add(curdate(), interval 1 day))-to_days(curdate()) weekday("1997-11-29")
6
select period_add("9602",-12),period_diff(199505,"9404") ;
7
period_add("9602",-12) period_diff(199505,"9404")
9
select now()-now(),weekday(curdate())-weekday(now()),unix_timestamp()-unix_timestamp(now());
10
now()-now() weekday(curdate())-weekday(now()) unix_timestamp()-unix_timestamp(now())
12
select from_unixtime(unix_timestamp("1994-03-02 10:11:12")),from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s"),from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0;
13
from_unixtime(unix_timestamp("1994-03-02 10:11:12")) from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s") from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0
14
1994-03-02 10:11:12 1994-03-02 10:11:12 19940302101112.000000
15
select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22"),
16
sec_to_time(time_to_sec("0:30:47")/6.21);
17
sec_to_time(9001) sec_to_time(9001)+0 time_to_sec("15:12:22") sec_to_time(time_to_sec("0:30:47")/6.21)
18
02:30:01 23001.000000 54742 00:04:57
19
select sec_to_time(time_to_sec('-838:59:59'));
20
sec_to_time(time_to_sec('-838:59:59'))
22
select now()-curdate()*1000000-curtime();
23
now()-curdate()*1000000-curtime()
25
select strcmp(current_timestamp(),concat(current_date()," ",current_time()));
26
strcmp(current_timestamp(),concat(current_date()," ",current_time()))
28
select strcmp(localtime(),concat(current_date()," ",current_time()));
29
strcmp(localtime(),concat(current_date()," ",current_time()))
31
select strcmp(localtimestamp(),concat(current_date()," ",current_time()));
32
strcmp(localtimestamp(),concat(current_date()," ",current_time()))
34
select date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w");
35
date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w")
36
January Thursday 2nd 1997 97 01 02 03 04 05 4
37
select date_format("1997-01-02", concat("%M %W %D ","%Y %y %m %d %h %i %s %w"));
38
date_format("1997-01-02", concat("%M %W %D ","%Y %y %m %d %h %i %s %w"))
39
January Thursday 2nd 1997 97 01 02 12 00 00 4
40
select dayofmonth("1997-01-02"),dayofmonth(19970323);
41
dayofmonth("1997-01-02") dayofmonth(19970323)
43
select month("1997-01-02"),year("98-02-03"),dayofyear("1997-12-31");
44
month("1997-01-02") year("98-02-03") dayofyear("1997-12-31")
46
select month("2001-02-00"),year("2001-00-00");
47
month("2001-02-00") year("2001-00-00")
49
select DAYOFYEAR("1997-03-03"), WEEK("1998-03-03"), QUARTER(980303);
50
DAYOFYEAR("1997-03-03") WEEK("1998-03-03") QUARTER(980303)
52
select HOUR("1997-03-03 23:03:22"), MINUTE("23:03:22"), SECOND(230322);
53
HOUR("1997-03-03 23:03:22") MINUTE("23:03:22") SECOND(230322)
55
select week(19980101),week(19970101),week(19980101,1),week(19970101,1);
56
week(19980101) week(19970101) week(19980101,1) week(19970101,1)
58
select week(19981231),week(19971231),week(19981231,1),week(19971231,1);
59
week(19981231) week(19971231) week(19981231,1) week(19971231,1)
61
select week(19950101),week(19950101,1);
62
week(19950101) week(19950101,1)
64
select yearweek('1981-12-31',1),yearweek('1982-01-01',1),yearweek('1982-12-31',1),yearweek('1983-01-01',1);
65
yearweek('1981-12-31',1) yearweek('1982-01-01',1) yearweek('1982-12-31',1) yearweek('1983-01-01',1)
66
198153 198153 198252 198252
67
select yearweek('1987-01-01',1),yearweek('1987-01-01');
68
yearweek('1987-01-01',1) yearweek('1987-01-01')
70
select week("2000-01-01",0) as '2000', week("2001-01-01",0) as '2001', week("2002-01-01",0) as '2002',week("2003-01-01",0) as '2003', week("2004-01-01",0) as '2004', week("2005-01-01",0) as '2005', week("2006-01-01",0) as '2006';
71
2000 2001 2002 2003 2004 2005 2006
73
select week("2000-01-06",0) as '2000', week("2001-01-06",0) as '2001', week("2002-01-06",0) as '2002',week("2003-01-06",0) as '2003', week("2004-01-06",0) as '2004', week("2005-01-06",0) as '2005', week("2006-01-06",0) as '2006';
74
2000 2001 2002 2003 2004 2005 2006
76
select week("2000-01-01",1) as '2000', week("2001-01-01",1) as '2001', week("2002-01-01",1) as '2002',week("2003-01-01",1) as '2003', week("2004-01-01",1) as '2004', week("2005-01-01",1) as '2005', week("2006-01-01",1) as '2006';
77
2000 2001 2002 2003 2004 2005 2006
79
select week("2000-01-06",1) as '2000', week("2001-01-06",1) as '2001', week("2002-01-06",1) as '2002',week("2003-01-06",1) as '2003', week("2004-01-06",1) as '2004', week("2005-01-06",1) as '2005', week("2006-01-06",1) as '2006';
80
2000 2001 2002 2003 2004 2005 2006
82
select yearweek("2000-01-01",0) as '2000', yearweek("2001-01-01",0) as '2001', yearweek("2002-01-01",0) as '2002',yearweek("2003-01-01",0) as '2003', yearweek("2004-01-01",0) as '2004', yearweek("2005-01-01",0) as '2005', yearweek("2006-01-01",0) as '2006';
83
2000 2001 2002 2003 2004 2005 2006
84
199952 200053 200152 200252 200352 200452 200601
85
select yearweek("2000-01-06",0) as '2000', yearweek("2001-01-06",0) as '2001', yearweek("2002-01-06",0) as '2002',yearweek("2003-01-06",0) as '2003', yearweek("2004-01-06",0) as '2004', yearweek("2005-01-06",0) as '2005', yearweek("2006-01-06",0) as '2006';
86
2000 2001 2002 2003 2004 2005 2006
87
200001 200053 200201 200301 200401 200501 200601
88
select yearweek("2000-01-01",1) as '2000', yearweek("2001-01-01",1) as '2001', yearweek("2002-01-01",1) as '2002',yearweek("2003-01-01",1) as '2003', yearweek("2004-01-01",1) as '2004', yearweek("2005-01-01",1) as '2005', yearweek("2006-01-01",1) as '2006';
89
2000 2001 2002 2003 2004 2005 2006
90
199952 200101 200201 200301 200401 200453 200552
91
select yearweek("2000-01-06",1) as '2000', yearweek("2001-01-06",1) as '2001', yearweek("2002-01-06",1) as '2002',yearweek("2003-01-06",1) as '2003', yearweek("2004-01-06",1) as '2004', yearweek("2005-01-06",1) as '2005', yearweek("2006-01-06",1) as '2006';
92
2000 2001 2002 2003 2004 2005 2006
93
200001 200101 200201 200302 200402 200501 200601
94
select week(19981231,2), week(19981231,3), week(20000101,2), week(20000101,3);
95
week(19981231,2) week(19981231,3) week(20000101,2) week(20000101,3)
97
select week(20001231,2),week(20001231,3);
98
week(20001231,2) week(20001231,3)
100
select week(19981231,0) as '0', week(19981231,1) as '1', week(19981231,2) as '2', week(19981231,3) as '3', week(19981231,4) as '4', week(19981231,5) as '5', week(19981231,6) as '6', week(19981231,7) as '7';
102
52 53 52 53 52 52 52 52
103
select week(20000101,0) as '0', week(20000101,1) as '1', week(20000101,2) as '2', week(20000101,3) as '3', week(20000101,4) as '4', week(20000101,5) as '5', week(20000101,6) as '6', week(20000101,7) as '7';
106
select week(20000106,0) as '0', week(20000106,1) as '1', week(20000106,2) as '2', week(20000106,3) as '3', week(20000106,4) as '4', week(20000106,5) as '5', week(20000106,6) as '6', week(20000106,7) as '7';
109
select week(20001231,0) as '0', week(20001231,1) as '1', week(20001231,2) as '2', week(20001231,3) as '3', week(20001231,4) as '4', week(20001231,5) as '5', week(20001231,6) as '6', week(20001231,7) as '7';
111
53 52 53 52 53 52 1 52
112
select week(20010101,0) as '0', week(20010101,1) as '1', week(20010101,2) as '2', week(20010101,3) as '3', week(20010101,4) as '4', week(20010101,5) as '5', week(20010101,6) as '6', week(20010101,7) as '7';
115
select yearweek(20001231,0), yearweek(20001231,1), yearweek(20001231,2), yearweek(20001231,3), yearweek(20001231,4), yearweek(20001231,5), yearweek(20001231,6), yearweek(20001231,7);
116
yearweek(20001231,0) yearweek(20001231,1) yearweek(20001231,2) yearweek(20001231,3) yearweek(20001231,4) yearweek(20001231,5) yearweek(20001231,6) yearweek(20001231,7)
117
200053 200052 200053 200052 200101 200052 200101 200052
118
set default_week_format = 6;
119
select week(20001231), week(20001231,6);
120
week(20001231) week(20001231,6)
122
set default_week_format = 0;
123
set default_week_format = 2;
124
select week(20001231),week(20001231,2),week(20001231,0);
125
week(20001231) week(20001231,2) week(20001231,0)
127
set default_week_format = 0;
128
select date_format('1998-12-31','%x-%v'),date_format('1999-01-01','%x-%v');
129
date_format('1998-12-31','%x-%v') date_format('1999-01-01','%x-%v')
131
select date_format('1999-12-31','%x-%v'),date_format('2000-01-01','%x-%v');
132
date_format('1999-12-31','%x-%v') date_format('2000-01-01','%x-%v')
134
select dayname("1962-03-03"),dayname("1962-03-03")+0;
135
dayname("1962-03-03") dayname("1962-03-03")+0
137
select monthname("1972-03-04"),monthname("1972-03-04")+0;
138
monthname("1972-03-04") monthname("1972-03-04")+0
140
select time_format(19980131000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
141
time_format(19980131000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T')
142
00|12|0|12|00|AM|12:00:00 AM|00|00:00:00
143
select time_format(19980131010203,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
144
time_format(19980131010203,'%H|%I|%k|%l|%i|%p|%r|%S|%T')
145
01|01|1|1|02|AM|01:02:03 AM|03|01:02:03
146
select time_format(19980131131415,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
147
time_format(19980131131415,'%H|%I|%k|%l|%i|%p|%r|%S|%T')
148
13|01|13|1|14|PM|01:14:15 PM|15|13:14:15
149
select time_format(19980131010015,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
150
time_format(19980131010015,'%H|%I|%k|%l|%i|%p|%r|%S|%T')
151
01|01|1|1|00|AM|01:00:15 AM|15|01:00:15
152
select date_format(concat('19980131',131415),'%H|%I|%k|%l|%i|%p|%r|%S|%T| %M|%W|%D|%Y|%y|%a|%b|%j|%m|%d|%h|%s|%w');
153
date_format(concat('19980131',131415),'%H|%I|%k|%l|%i|%p|%r|%S|%T| %M|%W|%D|%Y|%y|%a|%b|%j|%m|%d|%h|%s|%w')
154
13|01|13|1|14|PM|01:14:15 PM|15|13:14:15| January|Saturday|31st|1998|98|Sat|Jan|031|01|31|01|15|6
155
select date_format(19980021000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T| %M|%W|%D|%Y|%y|%a|%b|%j|%m|%d|%h|%s|%w');
156
date_format(19980021000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T| %M|%W|%D|%Y|%y|%a|%b|%j|%m|%d|%h|%s|%w')
158
select date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND);
159
date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND)
161
select date_add("1997-12-31 23:59:59",INTERVAL 1 MINUTE);
162
date_add("1997-12-31 23:59:59",INTERVAL 1 MINUTE)
164
select date_add("1997-12-31 23:59:59",INTERVAL 1 HOUR);
165
date_add("1997-12-31 23:59:59",INTERVAL 1 HOUR)
167
select date_add("1997-12-31 23:59:59",INTERVAL 1 DAY);
168
date_add("1997-12-31 23:59:59",INTERVAL 1 DAY)
170
select date_add("1997-12-31 23:59:59",INTERVAL 1 MONTH);
171
date_add("1997-12-31 23:59:59",INTERVAL 1 MONTH)
173
select date_add("1997-12-31 23:59:59",INTERVAL 1 YEAR);
174
date_add("1997-12-31 23:59:59",INTERVAL 1 YEAR)
176
select date_add("1997-12-31 23:59:59",INTERVAL "1:1" MINUTE_SECOND);
177
date_add("1997-12-31 23:59:59",INTERVAL "1:1" MINUTE_SECOND)
179
select date_add("1997-12-31 23:59:59",INTERVAL "1:1" HOUR_MINUTE);
180
date_add("1997-12-31 23:59:59",INTERVAL "1:1" HOUR_MINUTE)
182
select date_add("1997-12-31 23:59:59",INTERVAL "1:1" DAY_HOUR);
183
date_add("1997-12-31 23:59:59",INTERVAL "1:1" DAY_HOUR)
185
select date_add("1997-12-31 23:59:59",INTERVAL "1 1" YEAR_MONTH);
186
date_add("1997-12-31 23:59:59",INTERVAL "1 1" YEAR_MONTH)
188
select date_add("1997-12-31 23:59:59",INTERVAL "1:1:1" HOUR_SECOND);
189
date_add("1997-12-31 23:59:59",INTERVAL "1:1:1" HOUR_SECOND)
191
select date_add("1997-12-31 23:59:59",INTERVAL "1 1:1" DAY_MINUTE);
192
date_add("1997-12-31 23:59:59",INTERVAL "1 1:1" DAY_MINUTE)
194
select date_add("1997-12-31 23:59:59",INTERVAL "1 1:1:1" DAY_SECOND);
195
date_add("1997-12-31 23:59:59",INTERVAL "1 1:1:1" DAY_SECOND)
197
select date_sub("1998-01-01 00:00:00",INTERVAL 1 SECOND);
198
date_sub("1998-01-01 00:00:00",INTERVAL 1 SECOND)
200
select date_sub("1998-01-01 00:00:00",INTERVAL 1 MINUTE);
201
date_sub("1998-01-01 00:00:00",INTERVAL 1 MINUTE)
203
select date_sub("1998-01-01 00:00:00",INTERVAL 1 HOUR);
204
date_sub("1998-01-01 00:00:00",INTERVAL 1 HOUR)
206
select date_sub("1998-01-01 00:00:00",INTERVAL 1 DAY);
207
date_sub("1998-01-01 00:00:00",INTERVAL 1 DAY)
209
select date_sub("1998-01-01 00:00:00",INTERVAL 1 MONTH);
210
date_sub("1998-01-01 00:00:00",INTERVAL 1 MONTH)
212
select date_sub("1998-01-01 00:00:00",INTERVAL 1 YEAR);
213
date_sub("1998-01-01 00:00:00",INTERVAL 1 YEAR)
215
select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" MINUTE_SECOND);
216
date_sub("1998-01-01 00:00:00",INTERVAL "1:1" MINUTE_SECOND)
218
select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" HOUR_MINUTE);
219
date_sub("1998-01-01 00:00:00",INTERVAL "1:1" HOUR_MINUTE)
221
select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" DAY_HOUR);
222
date_sub("1998-01-01 00:00:00",INTERVAL "1:1" DAY_HOUR)
224
select date_sub("1998-01-01 00:00:00",INTERVAL "1 1" YEAR_MONTH);
225
date_sub("1998-01-01 00:00:00",INTERVAL "1 1" YEAR_MONTH)
227
select date_sub("1998-01-01 00:00:00",INTERVAL "1:1:1" HOUR_SECOND);
228
date_sub("1998-01-01 00:00:00",INTERVAL "1:1:1" HOUR_SECOND)
230
select date_sub("1998-01-01 00:00:00",INTERVAL "1 1:1" DAY_MINUTE);
231
date_sub("1998-01-01 00:00:00",INTERVAL "1 1:1" DAY_MINUTE)
233
select date_sub("1998-01-01 00:00:00",INTERVAL "1 1:1:1" DAY_SECOND);
234
date_sub("1998-01-01 00:00:00",INTERVAL "1 1:1:1" DAY_SECOND)
236
select date_add("1997-12-31 23:59:59",INTERVAL 100000 SECOND);
237
date_add("1997-12-31 23:59:59",INTERVAL 100000 SECOND)
239
select date_add("1997-12-31 23:59:59",INTERVAL -100000 MINUTE);
240
date_add("1997-12-31 23:59:59",INTERVAL -100000 MINUTE)
242
select date_add("1997-12-31 23:59:59",INTERVAL 100000 HOUR);
243
date_add("1997-12-31 23:59:59",INTERVAL 100000 HOUR)
245
select date_add("1997-12-31 23:59:59",INTERVAL -100000 DAY);
246
date_add("1997-12-31 23:59:59",INTERVAL -100000 DAY)
248
select date_add("1997-12-31 23:59:59",INTERVAL 100000 MONTH);
249
date_add("1997-12-31 23:59:59",INTERVAL 100000 MONTH)
252
Warning 1441 Datetime function: datetime field overflow
253
select date_add("1997-12-31 23:59:59",INTERVAL -100000 YEAR);
254
date_add("1997-12-31 23:59:59",INTERVAL -100000 YEAR)
257
Warning 1441 Datetime function: datetime field overflow
258
select date_add("1997-12-31 23:59:59",INTERVAL "10000:1" MINUTE_SECOND);
259
date_add("1997-12-31 23:59:59",INTERVAL "10000:1" MINUTE_SECOND)
261
select date_add("1997-12-31 23:59:59",INTERVAL "-10000:1" HOUR_MINUTE);
262
date_add("1997-12-31 23:59:59",INTERVAL "-10000:1" HOUR_MINUTE)
264
select date_add("1997-12-31 23:59:59",INTERVAL "10000:1" DAY_HOUR);
265
date_add("1997-12-31 23:59:59",INTERVAL "10000:1" DAY_HOUR)
267
select date_add("1997-12-31 23:59:59",INTERVAL "-100 1" YEAR_MONTH);
268
date_add("1997-12-31 23:59:59",INTERVAL "-100 1" YEAR_MONTH)
270
select date_add("1997-12-31 23:59:59",INTERVAL "10000:99:99" HOUR_SECOND);
271
date_add("1997-12-31 23:59:59",INTERVAL "10000:99:99" HOUR_SECOND)
273
select date_add("1997-12-31 23:59:59",INTERVAL " -10000 99:99" DAY_MINUTE);
274
date_add("1997-12-31 23:59:59",INTERVAL " -10000 99:99" DAY_MINUTE)
276
select date_add("1997-12-31 23:59:59",INTERVAL "10000 99:99:99" DAY_SECOND);
277
date_add("1997-12-31 23:59:59",INTERVAL "10000 99:99:99" DAY_SECOND)
279
select "1997-12-31 23:59:59" + INTERVAL 1 SECOND;
280
"1997-12-31 23:59:59" + INTERVAL 1 SECOND
282
select INTERVAL 1 DAY + "1997-12-31";
283
INTERVAL 1 DAY + "1997-12-31"
285
select "1998-01-01 00:00:00" - INTERVAL 1 SECOND;
286
"1998-01-01 00:00:00" - INTERVAL 1 SECOND
288
select date_sub("1998-01-02",INTERVAL 31 DAY);
289
date_sub("1998-01-02",INTERVAL 31 DAY)
291
select date_add("1997-12-31",INTERVAL 1 SECOND);
292
date_add("1997-12-31",INTERVAL 1 SECOND)
294
select date_add("1997-12-31",INTERVAL 1 DAY);
295
date_add("1997-12-31",INTERVAL 1 DAY)
297
select date_add(NULL,INTERVAL 100000 SECOND);
298
date_add(NULL,INTERVAL 100000 SECOND)
300
select date_add("1997-12-31 23:59:59",INTERVAL NULL SECOND);
301
date_add("1997-12-31 23:59:59",INTERVAL NULL SECOND)
303
select date_add("1997-12-31 23:59:59",INTERVAL NULL MINUTE_SECOND);
304
date_add("1997-12-31 23:59:59",INTERVAL NULL MINUTE_SECOND)
306
select date_add("9999-12-31 23:59:59",INTERVAL 1 SECOND);
307
date_add("9999-12-31 23:59:59",INTERVAL 1 SECOND)
310
Warning 1441 Datetime function: datetime field overflow
311
select date_sub("0000-00-00 00:00:00",INTERVAL 1 SECOND);
312
date_sub("0000-00-00 00:00:00",INTERVAL 1 SECOND)
315
Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
316
select date_add('1998-01-30',Interval 1 month);
317
date_add('1998-01-30',Interval 1 month)
319
select date_add('1998-01-30',Interval '2:1' year_month);
320
date_add('1998-01-30',Interval '2:1' year_month)
322
select date_add('1996-02-29',Interval '1' year);
323
date_add('1996-02-29',Interval '1' year)
325
select extract(YEAR FROM "1999-01-02 10:11:12");
326
extract(YEAR FROM "1999-01-02 10:11:12")
328
select extract(YEAR_MONTH FROM "1999-01-02");
329
extract(YEAR_MONTH FROM "1999-01-02")
331
select extract(DAY FROM "1999-01-02");
332
extract(DAY FROM "1999-01-02")
334
select extract(DAY_HOUR FROM "1999-01-02 10:11:12");
335
extract(DAY_HOUR FROM "1999-01-02 10:11:12")
337
select extract(DAY_MINUTE FROM "02 10:11:12");
338
extract(DAY_MINUTE FROM "02 10:11:12")
340
select extract(DAY_SECOND FROM "225 10:11:12");
341
extract(DAY_SECOND FROM "225 10:11:12")
344
Warning 1292 Truncated incorrect time value: '225 10:11:12'
345
select extract(HOUR FROM "1999-01-02 10:11:12");
346
extract(HOUR FROM "1999-01-02 10:11:12")
348
select extract(HOUR_MINUTE FROM "10:11:12");
349
extract(HOUR_MINUTE FROM "10:11:12")
351
select extract(HOUR_SECOND FROM "10:11:12");
352
extract(HOUR_SECOND FROM "10:11:12")
354
select extract(MINUTE FROM "10:11:12");
355
extract(MINUTE FROM "10:11:12")
357
select extract(MINUTE_SECOND FROM "10:11:12");
358
extract(MINUTE_SECOND FROM "10:11:12")
360
select extract(SECOND FROM "1999-01-02 10:11:12");
361
extract(SECOND FROM "1999-01-02 10:11:12")
363
select extract(MONTH FROM "2001-02-00");
364
extract(MONTH FROM "2001-02-00")
366
SELECT EXTRACT(QUARTER FROM '2004-01-15') AS quarter;
369
SELECT EXTRACT(QUARTER FROM '2004-02-15') AS quarter;
372
SELECT EXTRACT(QUARTER FROM '2004-03-15') AS quarter;
375
SELECT EXTRACT(QUARTER FROM '2004-04-15') AS quarter;
378
SELECT EXTRACT(QUARTER FROM '2004-05-15') AS quarter;
381
SELECT EXTRACT(QUARTER FROM '2004-06-15') AS quarter;
384
SELECT EXTRACT(QUARTER FROM '2004-07-15') AS quarter;
387
SELECT EXTRACT(QUARTER FROM '2004-08-15') AS quarter;
390
SELECT EXTRACT(QUARTER FROM '2004-09-15') AS quarter;
393
SELECT EXTRACT(QUARTER FROM '2004-10-15') AS quarter;
396
SELECT EXTRACT(QUARTER FROM '2004-11-15') AS quarter;
399
SELECT EXTRACT(QUARTER FROM '2004-12-15') AS quarter;
402
SELECT DATE_SUB(str_to_date('9999-12-31 00:01:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE);
403
DATE_SUB(str_to_date('9999-12-31 00:01:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE)
405
SELECT DATE_ADD(str_to_date('9999-12-30 23:59:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE);
406
DATE_ADD(str_to_date('9999-12-30 23:59:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE)
408
SELECT "1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND;
409
"1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND
411
SELECT "1900-01-01 00:00:00" + INTERVAL "1:2147483647" MINUTE_SECOND;
412
"1900-01-01 00:00:00" + INTERVAL "1:2147483647" MINUTE_SECOND
414
SELECT "1900-01-01 00:00:00" + INTERVAL "100000000:214748364700" MINUTE_SECOND;
415
"1900-01-01 00:00:00" + INTERVAL "100000000:214748364700" MINUTE_SECOND
417
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<37 SECOND;
418
"1900-01-01 00:00:00" + INTERVAL 1<<37 SECOND
420
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<31 MINUTE;
421
"1900-01-01 00:00:00" + INTERVAL 1<<31 MINUTE
423
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<20 HOUR;
424
"1900-01-01 00:00:00" + INTERVAL 1<<20 HOUR
426
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<38 SECOND;
427
"1900-01-01 00:00:00" + INTERVAL 1<<38 SECOND
430
Warning 1441 Datetime function: datetime field overflow
431
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<33 MINUTE;
432
"1900-01-01 00:00:00" + INTERVAL 1<<33 MINUTE
435
Warning 1441 Datetime function: datetime field overflow
436
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<30 HOUR;
437
"1900-01-01 00:00:00" + INTERVAL 1<<30 HOUR
440
Warning 1441 Datetime function: datetime field overflow
441
SELECT "1900-01-01 00:00:00" + INTERVAL "1000000000:214748364700" MINUTE_SECOND;
442
"1900-01-01 00:00:00" + INTERVAL "1000000000:214748364700" MINUTE_SECOND
445
Warning 1441 Datetime function: datetime field overflow
446
create table t1 (ctime varchar(20));
447
insert into t1 values ('2001-01-12 12:23:40');
448
select ctime, hour(ctime) from t1;
450
2001-01-12 12:23:40 12
451
select ctime from t1 where extract(MONTH FROM ctime) = 1 AND extract(YEAR FROM ctime) = 2001;
455
create table t1 (id int);
456
create table t2 (id int, date date);
457
insert into t1 values (1);
458
insert into t2 values (1, "0000-00-00");
459
insert into t1 values (2);
460
insert into t2 values (2, "2000-01-01");
461
select monthname(date) from t1 inner join t2 on t1.id = t2.id;
465
select monthname(date) from t1 inner join t2 on t1.id = t2.id order by t1.id;
470
CREATE TABLE t1 (updated text) ENGINE=MyISAM;
471
INSERT INTO t1 VALUES ('');
472
SELECT month(updated) from t1;
476
Warning 1292 Incorrect datetime value: ''
477
SELECT year(updated) from t1;
481
Warning 1292 Incorrect datetime value: ''
483
create table t1 (d date, dt datetime, t timestamp, c char(10));
484
insert into t1 values ("0000-00-00", "0000-00-00", "0000-00-00", "0000-00-00");
485
select dayofyear("0000-00-00"),dayofyear(d),dayofyear(dt),dayofyear(t),dayofyear(c) from t1;
486
dayofyear("0000-00-00") dayofyear(d) dayofyear(dt) dayofyear(t) dayofyear(c)
487
NULL NULL NULL NULL NULL
489
Warning 1292 Incorrect datetime value: '0000-00-00'
490
Warning 1292 Incorrect datetime value: '0000-00-00'
491
select dayofmonth("0000-00-00"),dayofmonth(d),dayofmonth(dt),dayofmonth(t),dayofmonth(c) from t1;
492
dayofmonth("0000-00-00") dayofmonth(d) dayofmonth(dt) dayofmonth(t) dayofmonth(c)
494
select month("0000-00-00"),month(d),month(dt),month(t),month(c) from t1;
495
month("0000-00-00") month(d) month(dt) month(t) month(c)
497
select quarter("0000-00-00"),quarter(d),quarter(dt),quarter(t),quarter(c) from t1;
498
quarter("0000-00-00") quarter(d) quarter(dt) quarter(t) quarter(c)
500
select week("0000-00-00"),week(d),week(dt),week(t),week(c) from t1;
501
week("0000-00-00") week(d) week(dt) week(t) week(c)
502
NULL NULL NULL NULL NULL
504
Warning 1292 Incorrect datetime value: '0000-00-00'
505
Warning 1292 Incorrect datetime value: '0000-00-00'
506
select year("0000-00-00"),year(d),year(dt),year(t),year(c) from t1;
507
year("0000-00-00") year(d) year(dt) year(t) year(c)
509
select yearweek("0000-00-00"),yearweek(d),yearweek(dt),yearweek(t),yearweek(c) from t1;
510
yearweek("0000-00-00") yearweek(d) yearweek(dt) yearweek(t) yearweek(c)
511
NULL NULL NULL NULL NULL
513
Warning 1292 Incorrect datetime value: '0000-00-00'
514
Warning 1292 Incorrect datetime value: '0000-00-00'
515
select to_days("0000-00-00"),to_days(d),to_days(dt),to_days(t),to_days(c) from t1;
516
to_days("0000-00-00") to_days(d) to_days(dt) to_days(t) to_days(c)
517
NULL NULL NULL NULL NULL
519
Warning 1292 Incorrect datetime value: '0000-00-00'
520
Warning 1292 Incorrect datetime value: '0000-00-00'
521
select extract(MONTH FROM "0000-00-00"),extract(MONTH FROM d),extract(MONTH FROM dt),extract(MONTH FROM t),extract(MONTH FROM c) from t1;
522
extract(MONTH FROM "0000-00-00") extract(MONTH FROM d) extract(MONTH FROM dt) extract(MONTH FROM t) extract(MONTH FROM c)
525
CREATE TABLE t1 ( start datetime default NULL);
526
INSERT INTO t1 VALUES ('2002-10-21 00:00:00'),('2002-10-28 00:00:00'),('2002-11-04 00:00:00');
527
CREATE TABLE t2 ( ctime1 timestamp NOT NULL, ctime2 timestamp NOT NULL);
528
INSERT INTO t2 VALUES (20021029165106,20021105164731);
529
CREATE TABLE t3 (ctime1 char(19) NOT NULL, ctime2 char(19) NOT NULL);
530
INSERT INTO t3 VALUES ("2002-10-29 16:51:06","2002-11-05 16:47:31");
531
select * from t1, t2 where t1.start between t2.ctime1 and t2.ctime2;
533
2002-11-04 00:00:00 2002-10-29 16:51:06 2002-11-05 16:47:31
534
select * from t1, t2 where t1.start >= t2.ctime1 and t1.start <= t2.ctime2;
536
2002-11-04 00:00:00 2002-10-29 16:51:06 2002-11-05 16:47:31
537
select * from t1, t3 where t1.start between t3.ctime1 and t3.ctime2;
539
2002-11-04 00:00:00 2002-10-29 16:51:06 2002-11-05 16:47:31
541
select @a:=FROM_UNIXTIME(1);
544
select unix_timestamp(@a);
547
select unix_timestamp('1969-12-01 19:00:01');
548
unix_timestamp('1969-12-01 19:00:01')
550
select from_unixtime(-1);
553
select from_unixtime(2147483647);
554
from_unixtime(2147483647)
556
select from_unixtime(2147483648);
557
from_unixtime(2147483648)
559
select from_unixtime(0);
562
select unix_timestamp(from_unixtime(2147483647));
563
unix_timestamp(from_unixtime(2147483647))
565
select unix_timestamp(from_unixtime(2147483648));
566
unix_timestamp(from_unixtime(2147483648))
568
select unix_timestamp('2039-01-20 01:00:00');
569
unix_timestamp('2039-01-20 01:00:00')
571
select unix_timestamp('1968-01-20 01:00:00');
572
unix_timestamp('1968-01-20 01:00:00')
574
select unix_timestamp('2038-02-10 01:00:00');
575
unix_timestamp('2038-02-10 01:00:00')
577
select unix_timestamp('1969-11-20 01:00:00');
578
unix_timestamp('1969-11-20 01:00:00')
580
select unix_timestamp('2038-01-20 01:00:00');
581
unix_timestamp('2038-01-20 01:00:00')
583
select unix_timestamp('1969-12-30 01:00:00');
584
unix_timestamp('1969-12-30 01:00:00')
586
select unix_timestamp('2038-01-17 12:00:00');
587
unix_timestamp('2038-01-17 12:00:00')
589
select unix_timestamp('1970-01-01 03:00:01');
590
unix_timestamp('1970-01-01 03:00:01')
592
select unix_timestamp('2038-01-19 07:14:07');
593
unix_timestamp('2038-01-19 07:14:07')
595
CREATE TABLE t1 (datetime datetime, timestamp timestamp, date date, time time);
596
INSERT INTO t1 values ("2001-01-02 03:04:05", "2002-01-02 03:04:05", "2003-01-02", "06:07:08");
598
datetime timestamp date time
599
2001-01-02 03:04:05 2002-01-02 03:04:05 2003-01-02 06:07:08
600
select date_add("1997-12-31",INTERVAL 1 SECOND);
601
date_add("1997-12-31",INTERVAL 1 SECOND)
603
select date_add("1997-12-31",INTERVAL "1 1" YEAR_MONTH);
604
date_add("1997-12-31",INTERVAL "1 1" YEAR_MONTH)
606
select date_add(datetime, INTERVAL 1 SECOND) from t1;
607
date_add(datetime, INTERVAL 1 SECOND)
609
select date_add(datetime, INTERVAL 1 YEAR) from t1;
610
date_add(datetime, INTERVAL 1 YEAR)
612
select date_add(date,INTERVAL 1 SECOND) from t1;
613
date_add(date,INTERVAL 1 SECOND)
615
select date_add(date,INTERVAL 1 MINUTE) from t1;
616
date_add(date,INTERVAL 1 MINUTE)
618
select date_add(date,INTERVAL 1 HOUR) from t1;
619
date_add(date,INTERVAL 1 HOUR)
621
select date_add(date,INTERVAL 1 DAY) from t1;
622
date_add(date,INTERVAL 1 DAY)
624
select date_add(date,INTERVAL 1 MONTH) from t1;
625
date_add(date,INTERVAL 1 MONTH)
627
select date_add(date,INTERVAL 1 YEAR) from t1;
628
date_add(date,INTERVAL 1 YEAR)
630
select date_add(date,INTERVAL "1:1" MINUTE_SECOND) from t1;
631
date_add(date,INTERVAL "1:1" MINUTE_SECOND)
633
select date_add(date,INTERVAL "1:1" HOUR_MINUTE) from t1;
634
date_add(date,INTERVAL "1:1" HOUR_MINUTE)
636
select date_add(date,INTERVAL "1:1" DAY_HOUR) from t1;
637
date_add(date,INTERVAL "1:1" DAY_HOUR)
639
select date_add(date,INTERVAL "1 1" YEAR_MONTH) from t1;
640
date_add(date,INTERVAL "1 1" YEAR_MONTH)
642
select date_add(date,INTERVAL "1:1:1" HOUR_SECOND) from t1;
643
date_add(date,INTERVAL "1:1:1" HOUR_SECOND)
645
select date_add(date,INTERVAL "1 1:1" DAY_MINUTE) from t1;
646
date_add(date,INTERVAL "1 1:1" DAY_MINUTE)
648
select date_add(date,INTERVAL "1 1:1:1" DAY_SECOND) from t1;
649
date_add(date,INTERVAL "1 1:1:1" DAY_SECOND)
651
select date_add(date,INTERVAL "1" WEEK) from t1;
652
date_add(date,INTERVAL "1" WEEK)
654
select date_add(date,INTERVAL "1" QUARTER) from t1;
655
date_add(date,INTERVAL "1" QUARTER)
657
select timestampadd(MINUTE, 1, date) from t1;
658
timestampadd(MINUTE, 1, date)
660
select timestampadd(WEEK, 1, date) from t1;
661
timestampadd(WEEK, 1, date)
663
select timestampadd(SQL_TSI_SECOND, 1, date) from t1;
664
timestampadd(SQL_TSI_SECOND, 1, date)
666
select timestampadd(SQL_TSI_FRAC_SECOND, 1, date) from t1;
667
timestampadd(SQL_TSI_FRAC_SECOND, 1, date)
668
2003-01-02 00:00:00.000001
670
Warning 1287 The syntax 'FRAC_SECOND' is deprecated and will be removed in MySQL 6.2. Please use MICROSECOND instead
671
select timestampdiff(MONTH, '2001-02-01', '2001-05-01') as a;
674
select timestampdiff(YEAR, '2002-05-01', '2001-01-01') as a;
677
select timestampdiff(QUARTER, '2002-05-01', '2001-01-01') as a;
680
select timestampdiff(MONTH, '2000-03-28', '2000-02-29') as a;
683
select timestampdiff(MONTH, '1991-03-28', '2000-02-29') as a;
686
select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a;
689
select timestampdiff(SQL_TSI_HOUR, '2001-02-01', '2001-05-01') as a;
692
select timestampdiff(SQL_TSI_DAY, '2001-02-01', '2001-05-01') as a;
695
select timestampdiff(SQL_TSI_MINUTE, '2001-02-01 12:59:59', '2001-05-01 12:58:59') as a;
698
select timestampdiff(SQL_TSI_SECOND, '2001-02-01 12:59:59', '2001-05-01 12:58:58') as a;
701
select timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a;
705
Warning 1287 The syntax 'FRAC_SECOND' is deprecated and will be removed in MySQL 6.2. Please use MICROSECOND instead
706
select timestampdiff(SQL_TSI_DAY, '1986-02-01', '1986-03-01') as a1,
707
timestampdiff(SQL_TSI_DAY, '1900-02-01', '1900-03-01') as a2,
708
timestampdiff(SQL_TSI_DAY, '1996-02-01', '1996-03-01') as a3,
709
timestampdiff(SQL_TSI_DAY, '2000-02-01', '2000-03-01') as a4;
712
SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:27');
713
TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:27')
715
SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:28');
716
TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:28')
718
SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:29');
719
TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:29')
721
SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:27');
722
TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:27')
724
SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:28');
725
TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:28')
727
SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:29');
728
TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:29')
730
SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:27');
731
TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:27')
733
SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:28');
734
TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:28')
736
SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:29');
737
TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:29')
739
SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:27');
740
TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:27')
742
SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:28');
743
TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:28')
745
SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:29');
746
TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:29')
748
SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:27');
749
TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:27')
751
SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:28');
752
TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:28')
754
SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:29');
755
TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:29')
757
SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:27');
758
TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:27')
760
SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:28');
761
TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:28')
763
SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:29');
764
TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:29')
766
SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:27');
767
TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:27')
769
SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:28');
770
TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:28')
772
SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:29');
773
TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:29')
775
SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:27');
776
TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:27')
778
SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:28');
779
TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:28')
781
SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:29');
782
TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:29')
784
select date_add(time,INTERVAL 1 SECOND) from t1;
785
date_add(time,INTERVAL 1 SECOND)
788
Warning 1264 Out of range value for column 'time' at row 1
790
select last_day('2000-02-05') as f1, last_day('2002-12-31') as f2,
791
last_day('2003-03-32') as f3, last_day('2003-04-01') as f4,
792
last_day('2001-01-01 01:01:01') as f5, last_day(NULL),
793
last_day('2001-02-12');
794
f1 f2 f3 f4 f5 last_day(NULL) last_day('2001-02-12')
795
2000-02-29 2002-12-31 NULL 2003-04-30 2001-01-31 NULL 2001-02-28
797
Warning 1292 Incorrect datetime value: '2003-03-32'
798
create table t1 select last_day('2000-02-05') as a,
799
from_days(to_days("960101")) as b;
801
Field Type Null Key Default Extra
806
2000-02-29 1996-01-01
808
select last_day('2000-02-05') as a,
809
from_days(to_days("960101")) as b;
811
2000-02-29 1996-01-01
812
select date_add(last_day("1997-12-1"), INTERVAL 1 DAY);
813
date_add(last_day("1997-12-1"), INTERVAL 1 DAY)
815
select length(last_day("1997-12-1"));
816
length(last_day("1997-12-1"))
818
select last_day("1997-12-1")+0;
819
last_day("1997-12-1")+0
821
select last_day("1997-12-1")+0.0;
822
last_day("1997-12-1")+0.0
824
select strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0;
825
strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0
827
select strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%T"), utc_time())=0;
828
strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%T"), utc_time())=0
830
select strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%Y-%m-%d"), utc_date())=0;
831
strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%Y-%m-%d"), utc_date())=0
833
select strcmp(date_format(utc_timestamp(),"%T"), utc_time())=0;
834
strcmp(date_format(utc_timestamp(),"%T"), utc_time())=0
836
select strcmp(date_format(utc_timestamp(),"%Y-%m-%d"), utc_date())=0;
837
strcmp(date_format(utc_timestamp(),"%Y-%m-%d"), utc_date())=0
839
select strcmp(concat(utc_date(),' ',utc_time()),utc_timestamp())=0;
840
strcmp(concat(utc_date(),' ',utc_time()),utc_timestamp())=0
842
explain extended select period_add("9602",-12),period_diff(199505,"9404"),from_days(to_days("960101")),dayofmonth("1997-01-02"), month("1997-01-02"), monthname("1972-03-04"),dayofyear("0000-00-00"),HOUR("1997-03-03 23:03:22"),MINUTE("23:03:22"),SECOND(230322),QUARTER(980303),WEEK("1998-03-03"),yearweek("2000-01-01",1),week(19950101,1),year("98-02-03"),weekday(curdate())-weekday(now()),dayname("1962-03-03"),unix_timestamp(),sec_to_time(time_to_sec("0:30:47")/6.21),curtime(),utc_time(),curdate(),utc_date(),utc_timestamp(),date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w"),from_unixtime(unix_timestamp("1994-03-02 10:11:12")),"1997-12-31 23:59:59" + INTERVAL 1 SECOND,"1998-01-01 00:00:00" - INTERVAL 1 SECOND,INTERVAL 1 DAY + "1997-12-31", extract(YEAR FROM "1999-01-02 10:11:12"),date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND);
843
id select_type table type possible_keys key key_len ref rows filtered Extra
844
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
846
Note 1003 select period_add('9602',-(12)) AS `period_add("9602",-12)`,period_diff(199505,'9404') AS `period_diff(199505,"9404")`,from_days(to_days('960101')) AS `from_days(to_days("960101"))`,dayofmonth('1997-01-02') AS `dayofmonth("1997-01-02")`,month('1997-01-02') AS `month("1997-01-02")`,monthname('1972-03-04') AS `monthname("1972-03-04")`,dayofyear('0000-00-00') AS `dayofyear("0000-00-00")`,hour('1997-03-03 23:03:22') AS `HOUR("1997-03-03 23:03:22")`,minute('23:03:22') AS `MINUTE("23:03:22")`,second(230322) AS `SECOND(230322)`,quarter(980303) AS `QUARTER(980303)`,week('1998-03-03',0) AS `WEEK("1998-03-03")`,yearweek('2000-01-01',1) AS `yearweek("2000-01-01",1)`,week(19950101,1) AS `week(19950101,1)`,year('98-02-03') AS `year("98-02-03")`,(weekday(curdate()) - weekday(now())) AS `weekday(curdate())-weekday(now())`,dayname('1962-03-03') AS `dayname("1962-03-03")`,unix_timestamp() AS `unix_timestamp()`,sec_to_time((time_to_sec('0:30:47') / 6.21)) AS `sec_to_time(time_to_sec("0:30:47")/6.21)`,curtime() AS `curtime()`,utc_time() AS `utc_time()`,curdate() AS `curdate()`,utc_date() AS `utc_date()`,utc_timestamp() AS `utc_timestamp()`,date_format('1997-01-02 03:04:05','%M %W %D %Y %y %m %d %h %i %s %w') AS `date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w")`,from_unixtime(unix_timestamp('1994-03-02 10:11:12')) AS `from_unixtime(unix_timestamp("1994-03-02 10:11:12"))`,('1997-12-31 23:59:59' + interval 1 second) AS `"1997-12-31 23:59:59" + INTERVAL 1 SECOND`,('1998-01-01 00:00:00' - interval 1 second) AS `"1998-01-01 00:00:00" - INTERVAL 1 SECOND`,('1997-12-31' + interval 1 day) AS `INTERVAL 1 DAY + "1997-12-31"`,extract(year from '1999-01-02 10:11:12') AS `extract(YEAR FROM "1999-01-02 10:11:12")`,('1997-12-31 23:59:59' + interval 1 second) AS `date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND)`
847
SET @TMP='2007-08-01 12:22:49';
848
CREATE TABLE t1 (d DATETIME);
849
INSERT INTO t1 VALUES ('2007-08-01 12:22:59');
850
INSERT INTO t1 VALUES ('2007-08-01 12:23:01');
851
INSERT INTO t1 VALUES ('2007-08-01 12:23:20');
852
SELECT count(*) FROM t1 WHERE d>FROM_DAYS(TO_DAYS(@TMP)) AND d<=FROM_DAYS(TO_DAYS(@TMP)+1);
856
select last_day('2005-00-00');
857
last_day('2005-00-00')
860
Warning 1292 Incorrect datetime value: '2005-00-00'
861
select last_day('2005-00-01');
862
last_day('2005-00-01')
865
Warning 1292 Incorrect datetime value: '2005-00-01'
866
select last_day('2005-01-00');
867
last_day('2005-01-00')
870
Warning 1292 Incorrect datetime value: '2005-01-00'
871
select monthname(str_to_date(null, '%m')), monthname(str_to_date(null, '%m')),
872
monthname(str_to_date(1, '%m')), monthname(str_to_date(0, '%m'));
873
monthname(str_to_date(null, '%m')) monthname(str_to_date(null, '%m')) monthname(str_to_date(1, '%m')) monthname(str_to_date(0, '%m'))
874
NULL NULL January NULL
875
set time_zone='-6:00';
876
create table t1(a timestamp);
877
insert into t1 values (19691231190001);
882
create table t1(f1 date, f2 time, f3 datetime);
883
insert into t1 values ("2006-01-01", "12:01:01", "2006-01-01 12:01:01");
884
insert into t1 values ("2006-01-02", "12:01:02", "2006-01-02 12:01:02");
885
select f1 from t1 where f1 between CAST("2006-1-1" as date) and CAST(20060101 as date);
888
select f1 from t1 where f1 between cast("2006-1-1" as date) and cast("2006.1.1" as date);
891
select f1 from t1 where date(f1) between cast("2006-1-1" as date) and cast("2006.1.1" as date);
894
select f2 from t1 where f2 between cast("12:1:2" as time) and cast("12:2:2" as time);
897
select f2 from t1 where time(f2) between cast("12:1:2" as time) and cast("12:2:2" as time);
900
select f3 from t1 where f3 between cast("2006-1-1 12:1:1" as datetime) and cast("2006-1-1 12:1:2" as datetime);
903
select f3 from t1 where timestamp(f3) between cast("2006-1-1 12:1:1" as datetime) and cast("2006-1-1 12:1:2" as datetime);
906
select f1 from t1 where cast("2006-1-1" as date) between f1 and f3;
909
select f1 from t1 where cast("2006-1-1" as date) between date(f1) and date(f3);
912
select f1 from t1 where cast("2006-1-1" as date) between f1 and cast('zzz' as date);
915
Warning 1292 Incorrect datetime value: 'zzz'
916
Warning 1292 Incorrect datetime value: 'zzz'
917
select f1 from t1 where makedate(2006,1) between date(f1) and date(f3);
920
select f1 from t1 where makedate(2006,2) between date(f1) and date(f3);
924
create table t1 select now() - now(), curtime() - curtime(),
925
sec_to_time(1) + 0, from_unixtime(1) + 0;
926
show create table t1;
928
t1 CREATE TABLE `t1` (
929
`now() - now()` double(23,6) NOT NULL DEFAULT '0.000000',
930
`curtime() - curtime()` double(23,6) NOT NULL DEFAULT '0.000000',
931
`sec_to_time(1) + 0` double(23,6) DEFAULT NULL,
932
`from_unixtime(1) + 0` double(23,6) DEFAULT NULL
933
) ENGINE=MyISAM DEFAULT CHARSET=latin1
935
SELECT SEC_TO_TIME(3300000);
939
Warning 1292 Truncated incorrect time value: '3300000'
940
SELECT SEC_TO_TIME(3300000)+0;
941
SEC_TO_TIME(3300000)+0
944
Warning 1292 Truncated incorrect time value: '3300000'
945
SELECT SEC_TO_TIME(3600 * 4294967296);
946
SEC_TO_TIME(3600 * 4294967296)
949
Warning 1292 Truncated incorrect time value: '15461882265600'
950
SELECT TIME_TO_SEC('916:40:00');
951
TIME_TO_SEC('916:40:00')
954
Warning 1292 Truncated incorrect time value: '916:40:00'
955
SELECT ADDTIME('500:00:00', '416:40:00');
956
ADDTIME('500:00:00', '416:40:00')
959
Warning 1292 Truncated incorrect time value: '916:40:00'
960
SELECT ADDTIME('916:40:00', '416:40:00');
961
ADDTIME('916:40:00', '416:40:00')
964
Warning 1292 Truncated incorrect time value: '916:40:00'
965
Warning 1292 Truncated incorrect time value: '1255:39:59'
966
SELECT SUBTIME('916:40:00', '416:40:00');
967
SUBTIME('916:40:00', '416:40:00')
970
Warning 1292 Truncated incorrect time value: '916:40:00'
971
SELECT SUBTIME('-916:40:00', '416:40:00');
972
SUBTIME('-916:40:00', '416:40:00')
975
Warning 1292 Truncated incorrect time value: '-916:40:00'
976
Warning 1292 Truncated incorrect time value: '-1255:39:59'
977
SELECT MAKETIME(916,0,0);
981
Warning 1292 Truncated incorrect time value: '916:00:00'
982
SELECT MAKETIME(4294967296, 0, 0);
983
MAKETIME(4294967296, 0, 0)
986
Warning 1292 Truncated incorrect time value: '4294967296:00:00'
987
SELECT MAKETIME(-4294967296, 0, 0);
988
MAKETIME(-4294967296, 0, 0)
991
Warning 1292 Truncated incorrect time value: '-4294967296:00:00'
992
SELECT MAKETIME(0, 4294967296, 0);
993
MAKETIME(0, 4294967296, 0)
995
SELECT MAKETIME(0, 0, 4294967296);
996
MAKETIME(0, 0, 4294967296)
998
SELECT MAKETIME(CAST(-1 AS UNSIGNED), 0, 0);
999
MAKETIME(CAST(-1 AS UNSIGNED), 0, 0)
1002
Warning 1292 Truncated incorrect time value: '18446744073709551615:00:00'
1003
SELECT EXTRACT(HOUR FROM '100000:02:03');
1004
EXTRACT(HOUR FROM '100000:02:03')
1007
Warning 1292 Truncated incorrect time value: '100000:02:03'
1008
CREATE TABLE t1(f1 TIME);
1009
INSERT INTO t1 VALUES('916:00:00 a');
1011
Warning 1265 Data truncated for column 'f1' at row 1
1012
Warning 1264 Out of range value for column 'f1' at row 1
1017
SELECT SEC_TO_TIME(CAST(-1 AS UNSIGNED));
1018
SEC_TO_TIME(CAST(-1 AS UNSIGNED))
1021
Warning 1292 Truncated incorrect time value: '18446744073709551615'
1023
SET character_set_results = NULL;
1024
SHOW VARIABLES LIKE 'character_set_results';
1026
character_set_results
1027
CREATE TABLE testBug8868 (field1 DATE, field2 VARCHAR(32) CHARACTER SET BINARY);
1028
INSERT INTO testBug8868 VALUES ('2006-09-04', 'abcd');
1029
SELECT DATE_FORMAT(field1,'%b-%e %l:%i%p') as fmtddate, field2 FROM testBug8868;
1032
DROP TABLE testBug8868;
1037
INSERT INTO t1 VALUES (now()), (now());
1038
SELECT 1 FROM t1 ORDER BY MAKETIME(1, 1, a);
1043
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H)
1045
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H);
1048
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H)
1050
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H);
1053
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H)
1055
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H);
1058
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H)
1060
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H);
1063
select last_day('0000-00-00');
1064
last_day('0000-00-00')
1066
select isnull(week(now() + 0)), isnull(week(now() + 0.2)),
1067
week(20061108), week(20061108.01), week(20061108085411.000002);
1068
isnull(week(now() + 0)) isnull(week(now() + 0.2)) week(20061108) week(20061108.01) week(20061108085411.000002)
1071
explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1,
1072
timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2;
1073
id select_type table type possible_keys key key_len ref rows filtered Extra
1074
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
1076
Warning 1287 The syntax 'FRAC_SECOND' is deprecated and will be removed in MySQL 6.2. Please use MICROSECOND instead
1077
Note 1003 select timestampdiff(WEEK,'2001-02-01','2001-05-01') AS `a1`,timestampdiff(SECOND_FRAC,'2001-02-01 12:59:59.120000','2001-05-01 12:58:58.119999') AS `a2`
1078
select time_format('100:00:00', '%H %k %h %I %l');
1079
time_format('100:00:00', '%H %k %h %I %l')
1081
SET GLOBAL log_bin_trust_function_creators = 1;
1082
create table t1 (a timestamp default '2005-05-05 01:01:01',
1083
b timestamp default '2005-05-05 01:01:01');
1084
drop function if exists t_slow_sysdate;
1085
create function t_slow_sysdate() returns timestamp
1091
insert into t1 set a = sysdate(), b = t_slow_sysdate();//
1092
create trigger t_before before insert on t1
1094
set new.b = t_slow_sysdate();
1097
insert into t1 set a = sysdate();
1098
select a != b from t1;
1102
drop trigger t_before;
1103
drop function t_slow_sysdate;
1105
SET GLOBAL log_bin_trust_function_creators = 0;
1106
create table t1 (a datetime, i int, b datetime);
1107
insert into t1 select sysdate(), sleep(1), sysdate() from dual;
1108
select a != b from t1;
1112
create procedure t_sysdate()
1114
select sysdate() into @a;
1116
select sysdate() into @b;
1123
drop procedure t_sysdate;
1124
select timestampdiff(month,'2004-09-11','2004-09-11');
1125
timestampdiff(month,'2004-09-11','2004-09-11')
1127
select timestampdiff(month,'2004-09-11','2005-09-11');
1128
timestampdiff(month,'2004-09-11','2005-09-11')
1130
select timestampdiff(month,'2004-09-11','2006-09-11');
1131
timestampdiff(month,'2004-09-11','2006-09-11')
1133
select timestampdiff(month,'2004-09-11','2007-09-11');
1134
timestampdiff(month,'2004-09-11','2007-09-11')
1136
select timestampdiff(month,'2005-09-11','2004-09-11');
1137
timestampdiff(month,'2005-09-11','2004-09-11')
1139
select timestampdiff(month,'2005-09-11','2003-09-11');
1140
timestampdiff(month,'2005-09-11','2003-09-11')
1142
select timestampdiff(month,'2004-02-28','2005-02-28');
1143
timestampdiff(month,'2004-02-28','2005-02-28')
1145
select timestampdiff(month,'2004-02-29','2005-02-28');
1146
timestampdiff(month,'2004-02-29','2005-02-28')
1148
select timestampdiff(month,'2004-02-28','2005-02-28');
1149
timestampdiff(month,'2004-02-28','2005-02-28')
1151
select timestampdiff(month,'2004-03-29','2005-03-28');
1152
timestampdiff(month,'2004-03-29','2005-03-28')
1154
select timestampdiff(month,'2003-02-28','2004-02-29');
1155
timestampdiff(month,'2003-02-28','2004-02-29')
1157
select timestampdiff(month,'2003-02-28','2005-02-28');
1158
timestampdiff(month,'2003-02-28','2005-02-28')
1160
select timestampdiff(month,'1999-09-11','2001-10-10');
1161
timestampdiff(month,'1999-09-11','2001-10-10')
1163
select timestampdiff(month,'1999-09-11','2001-9-11');
1164
timestampdiff(month,'1999-09-11','2001-9-11')
1166
select timestampdiff(year,'1999-09-11','2001-9-11');
1167
timestampdiff(year,'1999-09-11','2001-9-11')
1169
select timestampdiff(year,'2004-02-28','2005-02-28');
1170
timestampdiff(year,'2004-02-28','2005-02-28')
1172
select timestampdiff(year,'2004-02-29','2005-02-28');
1173
timestampdiff(year,'2004-02-29','2005-02-28')
1175
CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, day date);
1176
CREATE TABLE t2 (id int NOT NULL PRIMARY KEY, day date);
1177
INSERT INTO t1 VALUES
1178
(1, '2005-06-01'), (2, '2005-02-01'), (3, '2005-07-01');
1179
INSERT INTO t2 VALUES
1180
(1, '2005-08-01'), (2, '2005-06-15'), (3, '2005-07-15');
1181
SELECT * FROM t1, t2
1182
WHERE t1.day BETWEEN
1183
'2005.09.01' - INTERVAL 6 MONTH AND t2.day;
1185
1 2005-06-01 1 2005-08-01
1186
3 2005-07-01 1 2005-08-01
1187
1 2005-06-01 2 2005-06-15
1188
1 2005-06-01 3 2005-07-15
1189
3 2005-07-01 3 2005-07-15
1190
SELECT * FROM t1, t2
1191
WHERE CAST(t1.day AS DATE) BETWEEN
1192
'2005.09.01' - INTERVAL 6 MONTH AND t2.day;
1194
1 2005-06-01 1 2005-08-01
1195
3 2005-07-01 1 2005-08-01
1196
1 2005-06-01 2 2005-06-15
1197
1 2005-06-01 3 2005-07-15
1198
3 2005-07-01 3 2005-07-15
1200
set time_zone= @@global.time_zone;
1201
select str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE;
1202
str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE
1204
create table t1 (field DATE);
1205
insert into t1 values ('2006-11-06');
1206
select * from t1 where field < '2006-11-06 04:08:36.0';
1209
select * from t1 where field = '2006-11-06 04:08:36.0';
1211
select * from t1 where field = '2006-11-06';
1214
select * from t1 where CAST(field as DATETIME) < '2006-11-06 04:08:36.0';
1217
select * from t1 where CAST(field as DATE) < '2006-11-06 04:08:36.0';
1221
CREATE TABLE t1 (a int, t1 time, t2 time, d date, PRIMARY KEY (a));
1222
INSERT INTO t1 VALUES (1, '10:00:00', NULL, NULL),
1223
(2, '11:00:00', '11:15:00', '1972-02-06');
1224
SELECT t1, t2, SEC_TO_TIME( TIME_TO_SEC( t2 ) - TIME_TO_SEC( t1 ) ), QUARTER(d)
1226
t1 t2 SEC_TO_TIME( TIME_TO_SEC( t2 ) - TIME_TO_SEC( t1 ) ) QUARTER(d)
1227
10:00:00 NULL NULL NULL
1228
11:00:00 11:15:00 00:15:00 1
1229
SELECT t1, t2, SEC_TO_TIME( TIME_TO_SEC( t2 ) - TIME_TO_SEC( t1 ) ), QUARTER(d)
1230
FROM t1 ORDER BY a DESC;
1231
t1 t2 SEC_TO_TIME( TIME_TO_SEC( t2 ) - TIME_TO_SEC( t1 ) ) QUARTER(d)
1232
11:00:00 11:15:00 00:15:00 1
1233
10:00:00 NULL NULL NULL
1235
SELECT TIME_FORMAT(SEC_TO_TIME(a),"%H:%i:%s") FROM (SELECT 3020399 AS a UNION SELECT 3020398 ) x GROUP BY 1;
1236
TIME_FORMAT(SEC_TO_TIME(a),"%H:%i:%s")
1240
create table t1 (a varchar(15) character set ascii not null);
1241
insert into t1 values ('070514-000000');
1242
select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
1243
concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull'))
1246
select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
1247
ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (swe7_swedish_ci,COERCIBLE) for operation 'concat'
1249
set lc_time_names=fr_FR;
1250
select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
1251
ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation 'concat'
1252
set lc_time_names=en_US;
1254
select DATE_ADD('20071108181000', INTERVAL 1 DAY);
1255
DATE_ADD('20071108181000', INTERVAL 1 DAY)
1257
select DATE_ADD(20071108181000, INTERVAL 1 DAY);
1258
DATE_ADD(20071108181000, INTERVAL 1 DAY)
1260
select DATE_ADD('20071108', INTERVAL 1 DAY);
1261
DATE_ADD('20071108', INTERVAL 1 DAY)
1263
select DATE_ADD(20071108, INTERVAL 1 DAY);
1264
DATE_ADD(20071108, INTERVAL 1 DAY)
1266
select LAST_DAY('2007-12-06 08:59:19.05') - INTERVAL 1 SECOND;
1267
LAST_DAY('2007-12-06 08:59:19.05') - INTERVAL 1 SECOND
1269
SELECT TIMESTAMPADD(FRAC_SECOND, 1, '2008-02-18');
1270
TIMESTAMPADD(FRAC_SECOND, 1, '2008-02-18')
1271
2008-02-18 00:00:00.000001
1273
Warning 1287 The syntax 'FRAC_SECOND' is deprecated and will be removed in MySQL 6.2. Please use MICROSECOND instead
1274
SELECT TIMESTAMPDIFF(FRAC_SECOND, '2008-02-17', '2008-02-18');
1275
TIMESTAMPDIFF(FRAC_SECOND, '2008-02-17', '2008-02-18')
1278
Warning 1287 The syntax 'FRAC_SECOND' is deprecated and will be removed in MySQL 6.2. Please use MICROSECOND instead
1279
SELECT DATE_ADD('2008-02-18', INTERVAL 1 FRAC_SECOND);
1280
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FRAC_SECOND)' at line 1
1281
SELECT DATE_SUB('2008-02-18', INTERVAL 1 FRAC_SECOND);
1282
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FRAC_SECOND)' at line 1
1283
SELECT '2008-02-18' + INTERVAL 1 FRAC_SECOND;
1284
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FRAC_SECOND' at line 1
1285
SELECT '2008-02-18' - INTERVAL 1 FRAC_SECOND;
1286
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FRAC_SECOND' at line 1
1288
select date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND);
1289
date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND)
1291
select date_sub("0199-01-01 00:00:01",INTERVAL 2 SECOND);
1292
date_sub("0199-01-01 00:00:01",INTERVAL 2 SECOND)
1294
select date_add("0199-12-31 23:59:59",INTERVAL 2 SECOND);
1295
date_add("0199-12-31 23:59:59",INTERVAL 2 SECOND)
1297
select date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND);
1298
date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND)
1300
select date_sub("0200-01-01 00:00:01",INTERVAL 1 SECOND);
1301
date_sub("0200-01-01 00:00:01",INTERVAL 1 SECOND)
1303
select date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND);
1304
date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND)
1306
select date_add("2001-01-01 23:59:59",INTERVAL -2000 YEAR);
1307
date_add("2001-01-01 23:59:59",INTERVAL -2000 YEAR)
1309
select date_sub("50-01-01 00:00:01",INTERVAL 2 SECOND);
1310
date_sub("50-01-01 00:00:01",INTERVAL 2 SECOND)
1312
select date_sub("90-01-01 00:00:01",INTERVAL 2 SECOND);
1313
date_sub("90-01-01 00:00:01",INTERVAL 2 SECOND)
1315
select date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND);
1316
date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND)
1318
select date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND);
1319
date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND)