~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/func_time.result

  • Committer: Brian Aker
  • Date: 2010-01-27 18:58:12 UTC
  • Revision ID: brian@gaz-20100127185812-n62n0vwetnx8jrjy
Remove dead code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
drop table if exists t1,t2,t3;
2
 
set time_zone="+03:00";
3
2
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
3
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")
5
4
1996-01-01      31      1       5
12
11
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
12
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
13
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'))
21
 
-838:59:59
22
 
select now()-curdate()*1000000-curtime();
23
 
now()-curdate()*1000000-curtime()
24
 
0.000000
25
 
select strcmp(current_timestamp(),concat(current_date()," ",current_time()));
26
 
strcmp(current_timestamp(),concat(current_date()," ",current_time()))
27
 
0
28
 
select strcmp(localtime(),concat(current_date()," ",current_time()));
29
 
strcmp(localtime(),concat(current_date()," ",current_time()))
30
 
0
31
 
select strcmp(localtimestamp(),concat(current_date()," ",current_time()));
32
 
strcmp(localtimestamp(),concat(current_date()," ",current_time()))
33
 
0
34
14
select date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w");
35
15
date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w")
36
16
January Thursday 2nd 1997 97 01 02 03 04 05 4
43
23
select month("1997-01-02"),year("98-02-03"),dayofyear("1997-12-31");
44
24
month("1997-01-02")     year("98-02-03")        dayofyear("1997-12-31")
45
25
1       1998    365
46
 
select month("2001-02-00"),year("2001-00-00");
47
 
month("2001-02-00")     year("2001-00-00")
48
 
2       2001
49
 
select DAYOFYEAR("1997-03-03"), WEEK("1998-03-03"), QUARTER(980303);
50
 
DAYOFYEAR("1997-03-03") WEEK("1998-03-03")      QUARTER(980303)
51
 
62      9       1
 
26
select month("2001-02-00"),year("2001-01-01");
 
27
ERROR HY000: Received an invalid datetime value '2001-02-00'.
 
28
select DAYOFYEAR("1997-03-03"), QUARTER(980303);
 
29
DAYOFYEAR("1997-03-03") QUARTER(980303)
 
30
62      1
52
31
select HOUR("1997-03-03 23:03:22"), MINUTE("23:03:22"), SECOND(230322);
53
32
HOUR("1997-03-03 23:03:22")     MINUTE("23:03:22")      SECOND(230322)
54
33
23      3       22
55
 
select week(19980101),week(19970101),week(19980101,1),week(19970101,1);
56
 
week(19980101)  week(19970101)  week(19980101,1)        week(19970101,1)
57
 
0       0       1       1
58
 
select week(19981231),week(19971231),week(19981231,1),week(19971231,1);
59
 
week(19981231)  week(19971231)  week(19981231,1)        week(19971231,1)
60
 
52      52      53      53
61
 
select week(19950101),week(19950101,1);
62
 
week(19950101)  week(19950101,1)
63
 
1       0
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')
69
 
198701  198652
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
72
 
0       0       0       0       0       0       1
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
75
 
1       0       1       1       1       1       1
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
78
 
0       1       1       1       1       0       0
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
81
 
1       1       1       2       2       1       1
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)
96
 
52      53      52      52
97
 
select week(20001231,2),week(20001231,3);
98
 
week(20001231,2)        week(20001231,3)
99
 
53      52
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';
101
 
0       1       2       3       4       5       6       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';
104
 
0       1       2       3       4       5       6       7
105
 
0       0       52      52      0       0       52      52
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';
107
 
0       1       2       3       4       5       6       7
108
 
1       1       1       1       1       1       1       1
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';
110
 
0       1       2       3       4       5       6       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';
113
 
0       1       2       3       4       5       6       7
114
 
0       1       53      1       1       1       1       1
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)
121
 
1       1
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)
126
 
53      53      53
127
 
set default_week_format = 0;
128
34
select date_format('1998-12-31','%x-%v'),date_format('1999-01-01','%x-%v');
129
35
date_format('1998-12-31','%x-%v')       date_format('1999-01-01','%x-%v')
130
36
1998-53 1998-53
335
241
extract(DAY_HOUR FROM "1999-01-02 10:11:12")
336
242
210
337
243
select extract(DAY_MINUTE FROM "02 10:11:12");
338
 
extract(DAY_MINUTE FROM "02 10:11:12")
339
 
21011
 
244
ERROR HY000: Received an invalid datetime value '02 10:11:12'.
340
245
select extract(DAY_SECOND FROM "225 10:11:12");
341
 
extract(DAY_SECOND FROM "225 10:11:12")
342
 
8385959
343
 
Warnings:
344
 
Warning 1292    Truncated incorrect time value: '225 10:11:12'
 
246
ERROR HY000: Received an invalid datetime value '225 10:11:12'.
345
247
select extract(HOUR FROM "1999-01-02 10:11:12");
346
248
extract(HOUR FROM "1999-01-02 10:11:12")
347
249
10
361
263
extract(SECOND FROM "1999-01-02 10:11:12")
362
264
12
363
265
select extract(MONTH FROM "2001-02-00");
364
 
extract(MONTH FROM "2001-02-00")
365
 
2
 
266
ERROR HY000: Received an invalid datetime value '2001-02-00'.
366
267
SELECT EXTRACT(QUARTER FROM '2004-01-15') AS quarter;
367
268
quarter
368
269
1
399
300
SELECT EXTRACT(QUARTER FROM '2004-12-15') AS quarter;
400
301
quarter
401
302
4
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)
404
 
9999-12-31 00:00:00
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)
407
 
9999-12-31 00:00:00
408
303
SELECT "1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND;
409
304
"1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND
410
305
1968-01-20 03:14:08
414
309
SELECT "1900-01-01 00:00:00" + INTERVAL "100000000:214748364700" MINUTE_SECOND;
415
310
"1900-01-01 00:00:00" + INTERVAL "100000000:214748364700" MINUTE_SECOND
416
311
8895-03-27 22:11:40
417
 
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<37 SECOND;
418
 
"1900-01-01 00:00:00" + INTERVAL 1<<37 SECOND
419
 
6255-04-08 15:04:32
420
 
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<31 MINUTE;
421
 
"1900-01-01 00:00:00" + INTERVAL 1<<31 MINUTE
422
 
5983-01-24 02:08:00
423
 
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<20 HOUR;
424
 
"1900-01-01 00:00:00" + INTERVAL 1<<20 HOUR
425
 
2019-08-15 16:00:00
426
 
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<38 SECOND;
427
 
"1900-01-01 00:00:00" + INTERVAL 1<<38 SECOND
428
 
NULL
429
 
Warnings:
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
433
 
NULL
434
 
Warnings:
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
438
 
NULL
439
 
Warnings:
440
 
Warning 1441    Datetime function: datetime field overflow
441
312
SELECT "1900-01-01 00:00:00" + INTERVAL "1000000000:214748364700" MINUTE_SECOND;
442
313
"1900-01-01 00:00:00" + INTERVAL "1000000000:214748364700" MINUTE_SECOND
443
314
NULL
455
326
create table t1 (id int);
456
327
create table t2 (id int, date date);
457
328
insert into t1 values (1);
458
 
insert into t2 values (1, "0000-00-00");
 
329
insert into t2 values (1, NULL);
459
330
insert into t1 values (2);
460
331
insert into t2 values (2, "2000-01-01");
461
332
select monthname(date) from t1 inner join t2 on t1.id = t2.id;
462
333
monthname(date)
463
334
NULL
464
 
January
 
335
NULL
465
336
select monthname(date) from t1 inner join t2 on t1.id = t2.id order by t1.id;
466
337
monthname(date)
467
338
NULL
468
 
January
 
339
NULL
469
340
drop table t1,t2;
470
 
CREATE TABLE t1 (updated text) ENGINE=MyISAM;
 
341
CREATE TEMPORARY TABLE t1 (updated text) ENGINE=MyISAM;
471
342
INSERT INTO t1 VALUES ('');
472
343
SELECT month(updated) from t1;
473
 
month(updated)
474
 
NULL
475
 
Warnings:
476
 
Warning 1292    Incorrect datetime value: ''
 
344
ERROR HY000: Received an invalid datetime value ''.
477
345
SELECT year(updated) from t1;
478
 
year(updated)
479
 
NULL
480
 
Warnings:
481
 
Warning 1292    Incorrect datetime value: ''
 
346
ERROR HY000: Received an invalid datetime value ''.
482
347
drop table t1;
483
348
create table t1 (d date, dt datetime, t timestamp, c char(10));
 
349
insert into t1 values (null, null, null, null);
484
350
insert into t1 values ("0000-00-00", "0000-00-00", "0000-00-00", "0000-00-00");
 
351
ERROR HY000: Received an invalid datetime value '0000-00-00'.
485
352
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
488
 
Warnings:
489
 
Warning 1292    Incorrect datetime value: '0000-00-00'
490
 
Warning 1292    Incorrect datetime value: '0000-00-00'
 
353
ERROR HY000: Received an invalid datetime value '0000-00-00'.
491
354
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)
493
 
0       0       0       0       0
 
355
ERROR HY000: Received an invalid datetime value '0000-00-00'.
494
356
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)
496
 
0       0       0       0       0
 
357
ERROR HY000: Received an invalid datetime value '0000-00-00'.
497
358
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)
499
 
0       0       0       0       0
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
503
 
Warnings:
504
 
Warning 1292    Incorrect datetime value: '0000-00-00'
505
 
Warning 1292    Incorrect datetime value: '0000-00-00'
 
359
ERROR HY000: Received an invalid datetime value '0000-00-00'.
506
360
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)
508
 
0       0       0       0       0
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
512
 
Warnings:
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
518
 
Warnings:
519
 
Warning 1292    Incorrect datetime value: '0000-00-00'
520
 
Warning 1292    Incorrect datetime value: '0000-00-00'
 
361
ERROR HY000: Received an invalid datetime value '0000-00-00'.
 
362
select to_days("0000-00-00"),to_days(d),to_days(dt),to_days(c) from t1;
 
363
ERROR HY000: Received an invalid datetime value '0000-00-00'.
521
364
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)
523
 
0       0       0       0       0
 
365
ERROR HY000: Received an invalid datetime value '0000-00-00'.
524
366
drop table t1;
525
367
CREATE TABLE t1 ( start datetime default NULL);
526
368
INSERT INTO t1 VALUES ('2002-10-21 00:00:00'),('2002-10-28 00:00:00'),('2002-11-04 00:00:00');
540
382
drop table t1,t2,t3;
541
383
select @a:=FROM_UNIXTIME(1);
542
384
@a:=FROM_UNIXTIME(1)
543
 
1970-01-01 03:00:01
 
385
1970-01-01 00:00:01
544
386
select unix_timestamp(@a);
545
387
unix_timestamp(@a)
546
388
1
547
 
select unix_timestamp('1969-12-01 19:00:01');
548
 
unix_timestamp('1969-12-01 19:00:01')
549
 
0
 
389
select unix_timestamp('1970-01-01 00:00:01');
 
390
unix_timestamp('1970-01-01 00:00:01')
 
391
1
550
392
select from_unixtime(-1);
551
393
from_unixtime(-1)
552
394
NULL
553
395
select from_unixtime(2147483647);
554
396
from_unixtime(2147483647)
555
 
2038-01-19 06:14:07
 
397
2038-01-19 03:14:07
556
398
select from_unixtime(2147483648);
557
399
from_unixtime(2147483648)
558
400
NULL
559
401
select from_unixtime(0);
560
402
from_unixtime(0)
561
 
1970-01-01 03:00:00
 
403
1970-01-01 00:00:00
562
404
select unix_timestamp(from_unixtime(2147483647));
563
405
unix_timestamp(from_unixtime(2147483647))
564
406
2147483647
566
408
unix_timestamp(from_unixtime(2147483648))
567
409
NULL
568
410
select unix_timestamp('2039-01-20 01:00:00');
569
 
unix_timestamp('2039-01-20 01:00:00')
570
 
0
 
411
ERROR HY000: Received an invalid value '2039-01-20 01:00:00' for a UNIX timestamp.
571
412
select unix_timestamp('1968-01-20 01:00:00');
572
 
unix_timestamp('1968-01-20 01:00:00')
573
 
0
 
413
ERROR HY000: Received an invalid value '1968-01-20 01:00:00' for a UNIX timestamp.
574
414
select unix_timestamp('2038-02-10 01:00:00');
575
 
unix_timestamp('2038-02-10 01:00:00')
576
 
0
 
415
ERROR HY000: Received an invalid value '2038-02-10 01:00:00' for a UNIX timestamp.
577
416
select unix_timestamp('1969-11-20 01:00:00');
578
 
unix_timestamp('1969-11-20 01:00:00')
579
 
0
 
417
ERROR HY000: Received an invalid value '1969-11-20 01:00:00' for a UNIX timestamp.
580
418
select unix_timestamp('2038-01-20 01:00:00');
581
 
unix_timestamp('2038-01-20 01:00:00')
582
 
0
 
419
ERROR HY000: Received an invalid value '2038-01-20 01:00:00' for a UNIX timestamp.
583
420
select unix_timestamp('1969-12-30 01:00:00');
584
 
unix_timestamp('1969-12-30 01:00:00')
585
 
0
 
421
ERROR HY000: Received an invalid value '1969-12-30 01:00:00' for a UNIX timestamp.
586
422
select unix_timestamp('2038-01-17 12:00:00');
587
423
unix_timestamp('2038-01-17 12:00:00')
588
 
2147331600
589
 
select unix_timestamp('1970-01-01 03:00:01');
590
 
unix_timestamp('1970-01-01 03:00:01')
591
 
1
592
 
select unix_timestamp('2038-01-19 07:14:07');
593
 
unix_timestamp('2038-01-19 07:14:07')
594
 
0
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");
 
424
2147342400
 
425
select unix_timestamp('2038-01-19 03:14:07');
 
426
unix_timestamp('2038-01-19 03:14:07')
 
427
2147483647
 
428
CREATE TABLE t1 (datetime datetime, timestamp timestamp, date date);
 
429
INSERT INTO t1 values ("2001-01-02 03:04:05", "2002-01-02 03:04:05", "2003-01-02");
597
430
SELECT * from t1;
598
 
datetime        timestamp       date    time
599
 
2001-01-02 03:04:05     2002-01-02 03:04:05     2003-01-02      06:07:08
 
431
datetime        timestamp       date
 
432
2001-01-02 03:04:05     2002-01-02 03:04:05     2003-01-02
600
433
select date_add("1997-12-31",INTERVAL 1 SECOND);
601
434
date_add("1997-12-31",INTERVAL 1 SECOND)
602
435
1997-12-31 00:00:01
666
499
select timestampadd(SQL_TSI_FRAC_SECOND, 1, date) from t1;
667
500
timestampadd(SQL_TSI_FRAC_SECOND, 1, date)
668
501
2003-01-02 00:00:00.000001
669
 
Warnings:
670
 
Warning 1287    The syntax 'FRAC_SECOND' is deprecated and will be removed in MySQL 6.2. Please use MICROSECOND instead
671
502
select timestampdiff(MONTH, '2001-02-01', '2001-05-01') as a;
672
503
a
673
504
3
701
532
select timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a;
702
533
a
703
534
7689538999999
704
 
Warnings:
705
 
Warning 1287    The syntax 'FRAC_SECOND' is deprecated and will be removed in MySQL 6.2. Please use MICROSECOND instead
706
535
select timestampdiff(SQL_TSI_DAY, '1986-02-01', '1986-03-01') as a1,
707
536
timestampdiff(SQL_TSI_DAY, '1900-02-01', '1900-03-01') as a2,
708
537
timestampdiff(SQL_TSI_DAY, '1996-02-01', '1996-03-01') as a3,
781
610
SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:29');
782
611
TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:29')
783
612
2
784
 
select date_add(time,INTERVAL 1 SECOND) from t1;
785
 
date_add(time,INTERVAL 1 SECOND)
 
613
drop table t1;
 
614
select last_day('2000-02-05');
 
615
last_day('2000-02-05')
 
616
2000-02-29
 
617
select last_day('2002-12-31');
 
618
last_day('2002-12-31')
 
619
2002-12-31
 
620
select last_day('2003-03-32');
 
621
ERROR HY000: Received an invalid datetime value '2003-03-32'.
 
622
select last_day('2003-04-01');
 
623
last_day('2003-04-01')
 
624
2003-04-30
 
625
select last_day('2001-01-01 01:01:01');
 
626
last_day('2001-01-01 01:01:01')
 
627
2001-01-31
 
628
select last_day(NULL);
 
629
last_day(NULL)
786
630
NULL
787
 
Warnings:
788
 
Warning 1264    Out of range value for column 'time' at row 1
789
 
drop table t1;
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
796
 
Warnings:
797
 
Warning 1292    Incorrect datetime value: '2003-03-32'
 
631
select last_day('2001-02-12');
 
632
last_day('2001-02-12')
 
633
2001-02-28
798
634
create table t1 select last_day('2000-02-05') as a,
799
635
from_days(to_days("960101")) as b;
800
636
describe t1;
801
637
Field   Type    Null    Key     Default Extra
802
 
a       date    NO              0000-00-00      
 
638
a       date    NO              NULL    
803
639
b       date    YES             NULL    
804
640
select * from t1;
805
641
a       b
821
657
select last_day("1997-12-1")+0.0;
822
658
last_day("1997-12-1")+0.0
823
659
19971231.0
824
 
select strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0;
825
 
strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0
826
 
1
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
829
 
1
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
832
 
1
833
 
select strcmp(date_format(utc_timestamp(),"%T"), utc_time())=0;
834
 
strcmp(date_format(utc_timestamp(),"%T"), utc_time())=0
 
660
select strcmp(date_sub(localtimestamp(), interval 0 hour), utc_timestamp())=0;
 
661
strcmp(date_sub(localtimestamp(), interval 0 hour), utc_timestamp())=0
 
662
1
 
663
select strcmp(date_format(date_sub(localtimestamp(), interval 0 hour),"%Y-%m-%d"), utc_date())=0;
 
664
strcmp(date_format(date_sub(localtimestamp(), interval 0 hour),"%Y-%m-%d"), utc_date())=0
835
665
1
836
666
select strcmp(date_format(utc_timestamp(),"%Y-%m-%d"), utc_date())=0;
837
667
strcmp(date_format(utc_timestamp(),"%Y-%m-%d"), utc_date())=0
838
668
1
839
 
select strcmp(concat(utc_date(),' ',utc_time()),utc_timestamp())=0;
840
 
strcmp(concat(utc_date(),' ',utc_time()),utc_timestamp())=0
841
 
1
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);
 
669
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),weekday(curdate())-weekday(now()),dayname("1962-03-03"),unix_timestamp(),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
670
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
844
671
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
845
672
Warnings:
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)`
 
673
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)`,(weekday(curdate()) - weekday(now())) AS `weekday(curdate())-weekday(now())`,dayname('1962-03-03') AS `dayname("1962-03-03")`,unix_timestamp() AS `unix_timestamp()`,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
674
SET @TMP='2007-08-01 12:22:49';
848
675
CREATE TABLE t1 (d DATETIME);
849
676
INSERT INTO t1 VALUES ('2007-08-01 12:22:59');
854
681
3
855
682
DROP TABLE t1;
856
683
select last_day('2005-00-00');
857
 
last_day('2005-00-00')
858
 
NULL
859
 
Warnings:
860
 
Warning 1292    Incorrect datetime value: '2005-00-00'
 
684
ERROR HY000: Received an invalid datetime value '2005-00-00'.
861
685
select last_day('2005-00-01');
862
 
last_day('2005-00-01')
863
 
NULL
864
 
Warnings:
865
 
Warning 1292    Incorrect datetime value: '2005-00-01'
 
686
ERROR HY000: Received an invalid datetime value '2005-00-01'.
866
687
select last_day('2005-01-00');
867
 
last_day('2005-01-00')
868
 
NULL
869
 
Warnings:
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);
878
 
select * from t1;
879
 
a
880
 
1969-12-31 19:00:01
881
 
drop table t1;
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");
 
688
ERROR HY000: Received an invalid datetime value '2005-01-00'.
 
689
create table t1(f1 date, f3 datetime);
 
690
insert into t1 values ("2006-01-01", "2006-01-01 12:01:01");
 
691
insert into t1 values ("2006-01-02", "2006-01-02 12:01:02");
885
692
select f1 from t1 where f1 between CAST("2006-1-1" as date) and CAST(20060101 as date);
886
693
f1
887
694
2006-01-01
891
698
select f1 from t1 where date(f1) between cast("2006-1-1" as date) and cast("2006.1.1" as date);
892
699
f1
893
700
2006-01-01
894
 
select f2 from t1 where f2 between cast("12:1:2" as time) and cast("12:2:2" as time);
895
 
f2
896
 
12:01:02
897
 
select f2 from t1 where time(f2) between cast("12:1:2" as time) and cast("12:2:2" as time);
898
 
f2
899
 
12:01:02
900
701
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);
901
702
f3
902
703
2006-01-01 12:01:01
913
714
f1
914
715
Warnings:
915
716
Warning 1292    Incorrect datetime value: 'zzz'
916
 
Warning 1292    Incorrect datetime value: 'zzz'
917
717
select f1 from t1 where makedate(2006,1) between date(f1) and date(f3);
918
718
f1
919
719
2006-01-01
921
721
f1
922
722
2006-01-02
923
723
drop table t1;
924
 
create table t1 select now() - now(), curtime() - curtime(), 
925
 
sec_to_time(1) + 0, from_unixtime(1) + 0;
926
 
show create table t1;
927
 
Table   Create Table
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
934
 
drop table t1;
935
 
SELECT SEC_TO_TIME(3300000);
936
 
SEC_TO_TIME(3300000)
937
 
838:59:59
938
 
Warnings:
939
 
Warning 1292    Truncated incorrect time value: '3300000'
940
 
SELECT SEC_TO_TIME(3300000)+0;
941
 
SEC_TO_TIME(3300000)+0
942
 
8385959.000000
943
 
Warnings:
944
 
Warning 1292    Truncated incorrect time value: '3300000'
945
 
SELECT SEC_TO_TIME(3600 * 4294967296);
946
 
SEC_TO_TIME(3600 * 4294967296)
947
 
838:59:59
948
 
Warnings:
949
 
Warning 1292    Truncated incorrect time value: '15461882265600'
950
 
SELECT TIME_TO_SEC('916:40:00');
951
 
TIME_TO_SEC('916:40:00')
952
 
3020399
953
 
Warnings:
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')
957
 
838:59:59
958
 
Warnings:
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')
962
 
838:59:59
963
 
Warnings:
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')
968
 
422:19:59
969
 
Warnings:
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')
973
 
-838:59:59
974
 
Warnings:
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);
978
 
MAKETIME(916,0,0)
979
 
838:59:59
980
 
Warnings:
981
 
Warning 1292    Truncated incorrect time value: '916:00:00'
982
 
SELECT MAKETIME(4294967296, 0, 0);
983
 
MAKETIME(4294967296, 0, 0)
984
 
838:59:59
985
 
Warnings:
986
 
Warning 1292    Truncated incorrect time value: '4294967296:00:00'
987
 
SELECT MAKETIME(-4294967296, 0, 0);
988
 
MAKETIME(-4294967296, 0, 0)
989
 
-838:59:59
990
 
Warnings:
991
 
Warning 1292    Truncated incorrect time value: '-4294967296:00:00'
992
 
SELECT MAKETIME(0, 4294967296, 0);
993
 
MAKETIME(0, 4294967296, 0)
994
 
NULL
995
 
SELECT MAKETIME(0, 0, 4294967296);
996
 
MAKETIME(0, 0, 4294967296)
997
 
NULL
998
 
SELECT MAKETIME(CAST(-1 AS UNSIGNED), 0, 0);
999
 
MAKETIME(CAST(-1 AS UNSIGNED), 0, 0)
1000
 
838:59:59
1001
 
Warnings:
1002
 
Warning 1292    Truncated incorrect time value: '18446744073709551615:00:00'
1003
724
SELECT EXTRACT(HOUR FROM '100000:02:03');
1004
 
EXTRACT(HOUR FROM '100000:02:03')
1005
 
838
1006
 
Warnings:
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');
1010
 
Warnings:
1011
 
Warning 1265    Data truncated for column 'f1' at row 1
1012
 
Warning 1264    Out of range value for column 'f1' at row 1
1013
 
SELECT * FROM t1;
1014
 
f1
1015
 
838:59:59
1016
 
DROP TABLE t1;
1017
 
SELECT SEC_TO_TIME(CAST(-1 AS UNSIGNED));
1018
 
SEC_TO_TIME(CAST(-1 AS UNSIGNED))
1019
 
838:59:59
1020
 
Warnings:
1021
 
Warning 1292    Truncated incorrect time value: '18446744073709551615'
1022
 
SET NAMES latin1;
1023
 
SET character_set_results = NULL;
 
725
ERROR HY000: Received an invalid datetime value '100000:02:03'.
1024
726
SHOW VARIABLES LIKE 'character_set_results';
1025
727
Variable_name   Value
1026
 
character_set_results   
1027
 
CREATE TABLE testBug8868 (field1 DATE, field2 VARCHAR(32) CHARACTER SET BINARY);
 
728
CREATE TABLE testBug8868 (field1 DATE, field2 VARCHAR(32));
1028
729
INSERT INTO testBug8868 VALUES ('2006-09-04', 'abcd');
1029
730
SELECT DATE_FORMAT(field1,'%b-%e %l:%i%p') as fmtddate, field2 FROM testBug8868;
1030
731
fmtddate        field2
1031
732
Sep-4 12:00AM   abcd
1032
733
DROP TABLE testBug8868;
1033
 
SET NAMES DEFAULT;
1034
 
CREATE TABLE t1 (
1035
 
a TIMESTAMP
1036
 
);
1037
 
INSERT INTO t1 VALUES (now()), (now());
1038
 
SELECT 1 FROM t1 ORDER BY MAKETIME(1, 1, a);
1039
 
1
1040
 
1
1041
 
1
1042
 
DROP TABLE t1;
1043
 
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H)
1044
 
union
1045
 
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H);
1046
 
H
1047
 
120
1048
 
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H)
1049
 
union
1050
 
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H);
1051
 
H
1052
 
120
1053
 
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H)
1054
 
union
1055
 
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H);
1056
 
H
1057
 
05
1058
 
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H)
1059
 
union
1060
 
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H);
1061
 
H
1062
 
5
1063
734
select last_day('0000-00-00');
1064
 
last_day('0000-00-00')
1065
 
NULL
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)
1069
 
0       0       45      45      45
 
735
ERROR HY000: Received an invalid datetime value '0000-00-00'.
1070
736
End of 4.1 tests
1071
737
explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1,
1072
738
timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2;
1073
739
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
1074
740
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
1075
741
Warnings:
1076
 
Warning 1287    The syntax 'FRAC_SECOND' is deprecated and will be removed in MySQL 6.2. Please use MICROSECOND instead
1077
742
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
743
select time_format('100:00:00', '%H %k %h %I %l');
1079
744
time_format('100:00:00', '%H %k %h %I %l')
1080
745
100 100 04 04 4
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
1086
 
begin
1087
 
do sleep(2);
1088
 
return sysdate();
1089
 
end;
1090
 
//
1091
 
insert into t1 set a = sysdate(), b = t_slow_sysdate();//
1092
 
create trigger t_before before insert on t1
1093
 
for each row begin
1094
 
set new.b = t_slow_sysdate();
1095
 
end
1096
 
//
1097
 
insert into t1 set a = sysdate();
1098
 
select a != b from t1;
1099
 
a != b
1100
 
1
1101
 
1
1102
 
drop trigger t_before;
1103
 
drop function t_slow_sysdate;
1104
 
drop table t1;
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;
1109
 
a != b
1110
 
1
1111
 
drop table t1;
1112
 
create procedure t_sysdate()
1113
 
begin
1114
 
select sysdate() into @a;
1115
 
do sleep(2);
1116
 
select sysdate() into @b;
1117
 
select @a != @b;
1118
 
end;
1119
 
//
1120
 
call t_sysdate();
1121
 
@a != @b
1122
 
1
1123
 
drop procedure t_sysdate;
1124
746
select timestampdiff(month,'2004-09-11','2004-09-11');
1125
747
timestampdiff(month,'2004-09-11','2004-09-11')
1126
748
0
1197
819
1       2005-06-01      3       2005-07-15
1198
820
3       2005-07-01      3       2005-07-15
1199
821
DROP TABLE t1,t2;
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
1203
 
NULL
1204
822
create table t1 (field DATE);
1205
823
insert into t1 values ('2006-11-06');
1206
824
select * from t1 where field < '2006-11-06 04:08:36.0';
1218
836
field
1219
837
2006-11-06
1220
838
drop table t1;
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) 
1225
 
FROM t1;
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
1234
 
DROP TABLE t1;
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")
1237
 
838:59:58
1238
 
838:59:59
1239
 
set names latin1;
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'))
1244
 
#
1245
 
set names swe7;
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'
1248
 
set names latin1;
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;
1253
 
drop table t1;
1254
839
select DATE_ADD('20071108181000', INTERVAL 1 DAY);
1255
840
DATE_ADD('20071108181000', INTERVAL 1 DAY)
1256
841
2007-11-09 18:10:00
1269
854
SELECT TIMESTAMPADD(FRAC_SECOND, 1, '2008-02-18');
1270
855
TIMESTAMPADD(FRAC_SECOND, 1, '2008-02-18')
1271
856
2008-02-18 00:00:00.000001
1272
 
Warnings:
1273
 
Warning 1287    The syntax 'FRAC_SECOND' is deprecated and will be removed in MySQL 6.2. Please use MICROSECOND instead
1274
857
SELECT TIMESTAMPDIFF(FRAC_SECOND, '2008-02-17', '2008-02-18');
1275
858
TIMESTAMPDIFF(FRAC_SECOND, '2008-02-17', '2008-02-18')
1276
859
86400000000
1277
 
Warnings:
1278
 
Warning 1287    The syntax 'FRAC_SECOND' is deprecated and will be removed in MySQL 6.2. Please use MICROSECOND instead
1279
860
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
 
861
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near 'FRAC_SECOND)' at line 1
1281
862
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
 
863
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near 'FRAC_SECOND)' at line 1
1283
864
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
 
865
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near 'FRAC_SECOND' at line 1
1285
866
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
 
867
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near 'FRAC_SECOND' at line 1
1287
868
End of 5.0 tests
1288
869
select date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND);
1289
870
date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND)