23
43
select month("1997-01-02"),year("98-02-03"),dayofyear("1997-12-31");
24
44
month("1997-01-02") year("98-02-03") dayofyear("1997-12-31")
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)
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)
31
52
select HOUR("1997-03-03 23:03:22"), MINUTE("23:03:22"), SECOND(230322);
32
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;
34
128
select date_format('1998-12-31','%x-%v'),date_format('1999-01-01','%x-%v');
35
129
date_format('1998-12-31','%x-%v') date_format('1999-01-01','%x-%v')
326
455
create table t1 (id int);
327
456
create table t2 (id int, date date);
328
457
insert into t1 values (1);
329
insert into t2 values (1, NULL);
458
insert into t2 values (1, "0000-00-00");
330
459
insert into t1 values (2);
331
460
insert into t2 values (2, "2000-01-01");
332
461
select monthname(date) from t1 inner join t2 on t1.id = t2.id;
336
465
select monthname(date) from t1 inner join t2 on t1.id = t2.id order by t1.id;
340
469
drop table t1,t2;
341
CREATE TEMPORARY TABLE t1 (updated text) ENGINE=MyISAM;
470
CREATE TABLE t1 (updated text) ENGINE=MyISAM;
342
471
INSERT INTO t1 VALUES ('');
343
472
SELECT month(updated) from t1;
344
ERROR HY000: Received an invalid datetime value ''.
476
Warning 1292 Incorrect datetime value: ''
345
477
SELECT year(updated) from t1;
346
ERROR HY000: Received an invalid datetime value ''.
481
Warning 1292 Incorrect datetime value: ''
348
483
create table t1 (d date, dt datetime, t timestamp, c char(10));
349
insert into t1 values (null, null, null, null);
350
484
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'.
352
485
select dayofyear("0000-00-00"),dayofyear(d),dayofyear(dt),dayofyear(t),dayofyear(c) from t1;
353
ERROR HY000: Received an invalid datetime value '0000-00-00'.
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'
354
491
select dayofmonth("0000-00-00"),dayofmonth(d),dayofmonth(dt),dayofmonth(t),dayofmonth(c) from t1;
355
ERROR HY000: Received an invalid datetime value '0000-00-00'.
492
dayofmonth("0000-00-00") dayofmonth(d) dayofmonth(dt) dayofmonth(t) dayofmonth(c)
356
494
select month("0000-00-00"),month(d),month(dt),month(t),month(c) from t1;
357
ERROR HY000: Received an invalid datetime value '0000-00-00'.
495
month("0000-00-00") month(d) month(dt) month(t) month(c)
358
497
select quarter("0000-00-00"),quarter(d),quarter(dt),quarter(t),quarter(c) from t1;
359
ERROR HY000: Received an invalid datetime value '0000-00-00'.
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'
360
506
select year("0000-00-00"),year(d),year(dt),year(t),year(c) from t1;
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'.
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'
364
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;
365
ERROR HY000: Received an invalid datetime value '0000-00-00'.
522
extract(MONTH FROM "0000-00-00") extract(MONTH FROM d) extract(MONTH FROM dt) extract(MONTH FROM t) extract(MONTH FROM c)
367
525
CREATE TABLE t1 ( start datetime default NULL);
368
526
INSERT INTO t1 VALUES ('2002-10-21 00:00:00'),('2002-10-28 00:00:00'),('2002-11-04 00:00:00');
408
566
unix_timestamp(from_unixtime(2147483648))
410
568
select unix_timestamp('2039-01-20 01:00:00');
411
ERROR HY000: Received an invalid value '2039-01-20 01:00:00' for a UNIX timestamp.
569
unix_timestamp('2039-01-20 01:00:00')
412
571
select unix_timestamp('1968-01-20 01:00:00');
413
ERROR HY000: Received an invalid value '1968-01-20 01:00:00' for a UNIX timestamp.
572
unix_timestamp('1968-01-20 01:00:00')
414
574
select unix_timestamp('2038-02-10 01:00:00');
415
ERROR HY000: Received an invalid value '2038-02-10 01:00:00' for a UNIX timestamp.
575
unix_timestamp('2038-02-10 01:00:00')
416
577
select unix_timestamp('1969-11-20 01:00:00');
417
ERROR HY000: Received an invalid value '1969-11-20 01:00:00' for a UNIX timestamp.
578
unix_timestamp('1969-11-20 01:00:00')
418
580
select unix_timestamp('2038-01-20 01:00:00');
419
ERROR HY000: Received an invalid value '2038-01-20 01:00:00' for a UNIX timestamp.
581
unix_timestamp('2038-01-20 01:00:00')
420
583
select unix_timestamp('1969-12-30 01:00:00');
421
ERROR HY000: Received an invalid value '1969-12-30 01:00:00' for a UNIX timestamp.
584
unix_timestamp('1969-12-30 01:00:00')
422
586
select unix_timestamp('2038-01-17 12:00:00');
423
587
unix_timestamp('2038-01-17 12:00:00')
425
select unix_timestamp('2038-01-19 03:14:07');
426
unix_timestamp('2038-01-19 03:14:07')
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");
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");
430
597
SELECT * from t1;
431
datetime timestamp date
432
2001-01-02 03:04:05 2002-01-02 03:04:05 2003-01-02
598
datetime timestamp date time
599
2001-01-02 03:04:05 2002-01-02 03:04:05 2003-01-02 06:07:08
433
600
select date_add("1997-12-31",INTERVAL 1 SECOND);
434
601
date_add("1997-12-31",INTERVAL 1 SECOND)
435
602
1997-12-31 00:00:01
657
821
select last_day("1997-12-1")+0.0;
658
822
last_day("1997-12-1")+0.0
660
select strcmp(date_sub(localtimestamp(), interval 0 hour), utc_timestamp())=0;
661
strcmp(date_sub(localtimestamp(), interval 0 hour), utc_timestamp())=0
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
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
666
836
select strcmp(date_format(utc_timestamp(),"%Y-%m-%d"), utc_date())=0;
667
837
strcmp(date_format(utc_timestamp(),"%Y-%m-%d"), utc_date())=0
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);
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);
670
843
id select_type table type possible_keys key key_len ref rows filtered Extra
671
844
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
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)`
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)`
674
847
SET @TMP='2007-08-01 12:22:49';
675
848
CREATE TABLE t1 (d DATETIME);
676
849
INSERT INTO t1 VALUES ('2007-08-01 12:22:59');
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'
724
1003
SELECT EXTRACT(HOUR FROM '100000:02:03');
725
ERROR HY000: Received an invalid datetime value '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;
726
1024
SHOW VARIABLES LIKE 'character_set_results';
727
1025
Variable_name Value
728
CREATE TABLE testBug8868 (field1 DATE, field2 VARCHAR(32));
1026
character_set_results
1027
CREATE TABLE testBug8868 (field1 DATE, field2 VARCHAR(32) CHARACTER SET BINARY);
729
1028
INSERT INTO testBug8868 VALUES ('2006-09-04', 'abcd');
730
1029
SELECT DATE_FORMAT(field1,'%b-%e %l:%i%p') as fmtddate, field2 FROM testBug8868;
732
1031
Sep-4 12:00AM abcd
733
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);
734
1063
select last_day('0000-00-00');
735
ERROR HY000: Received an invalid datetime value '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)
736
1070
End of 4.1 tests
737
1071
explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1,
738
1072
timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2;
739
1073
id select_type table type possible_keys key key_len ref rows filtered Extra
740
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
742
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`
743
1078
select time_format('100:00:00', '%H %k %h %I %l');
744
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;
746
1124
select timestampdiff(month,'2004-09-11','2004-09-11');
747
1125
timestampdiff(month,'2004-09-11','2004-09-11')
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;
839
1254
select DATE_ADD('20071108181000', INTERVAL 1 DAY);
840
1255
DATE_ADD('20071108181000', INTERVAL 1 DAY)
841
1256
2007-11-09 18:10:00