43
43
month("1997-01-02") year("98-02-03") dayofyear("1997-12-31")
45
45
select month("2001-02-00"),year("2001-01-01");
46
month("2001-02-00") year("2001-01-01")
46
ERROR HY000: Received an invalid datetime value '2001-02-00'.
48
47
select DAYOFYEAR("1997-03-03"), WEEK("1998-03-03"), QUARTER(980303);
49
48
DAYOFYEAR("1997-03-03") WEEK("1998-03-03") QUARTER(980303)
430
429
create table t1 (id int);
431
430
create table t2 (id int, date date);
432
431
insert into t1 values (1);
433
insert into t2 values (1, "0000-00-00");
432
insert into t2 values (1, NULL);
434
433
insert into t1 values (2);
435
434
insert into t2 values (2, "2000-01-01");
436
435
select monthname(date) from t1 inner join t2 on t1.id = t2.id;
440
439
select monthname(date) from t1 inner join t2 on t1.id = t2.id order by t1.id;
444
443
drop table t1,t2;
445
444
CREATE TABLE t1 (updated text) ENGINE=MyISAM;
446
445
INSERT INTO t1 VALUES ('');
447
446
SELECT month(updated) from t1;
451
Warning 1292 Incorrect datetime value: ''
447
ERROR HY000: Received an invalid datetime value ''.
452
448
SELECT year(updated) from t1;
453
449
ERROR HY000: Received an invalid datetime value ''.
455
451
create table t1 (d date, dt datetime, t timestamp, c char(10));
456
452
insert into t1 values ("0000-00-00", "0000-00-00", "0000-00-00", "0000-00-00");
457
453
select dayofyear("0000-00-00"),dayofyear(d),dayofyear(dt),dayofyear(t),dayofyear(c) from t1;
458
dayofyear("0000-00-00") dayofyear(d) dayofyear(dt) dayofyear(t) dayofyear(c)
459
NULL NULL NULL NULL NULL
461
Warning 1292 Incorrect datetime value: '0000-00-00'
462
Warning 1292 Incorrect datetime value: '0000-00-00'
454
ERROR HY000: Received an invalid datetime value '0000-00-00'.
463
455
select dayofmonth("0000-00-00"),dayofmonth(d),dayofmonth(dt),dayofmonth(t),dayofmonth(c) from t1;
464
dayofmonth("0000-00-00") dayofmonth(d) dayofmonth(dt) dayofmonth(t) dayofmonth(c)
456
ERROR HY000: Received an invalid datetime value '0000-00-00'.
466
457
select month("0000-00-00"),month(d),month(dt),month(t),month(c) from t1;
467
month("0000-00-00") month(d) month(dt) month(t) month(c)
458
ERROR HY000: Received an invalid datetime value '0000-00-00'.
469
459
select quarter("0000-00-00"),quarter(d),quarter(dt),quarter(t),quarter(c) from t1;
470
460
quarter("0000-00-00") quarter(d) quarter(dt) quarter(t) quarter(c)
837
827
Warning 1292 Incorrect datetime value: '2005-01-00'
838
828
select monthname(str_to_date(null, '%m')), monthname(str_to_date(null, '%m')),
839
829
monthname(str_to_date(1, '%m')), monthname(str_to_date(0, '%m'));
840
monthname(str_to_date(null, '%m')) monthname(str_to_date(null, '%m')) monthname(str_to_date(1, '%m')) monthname(str_to_date(0, '%m'))
841
NULL NULL January NULL
830
ERROR HY000: Received an invalid datetime value '0000-01-00'.
842
831
create table t1(f1 date, f2 time, f3 datetime);
843
832
insert into t1 values ("2006-01-01", "12:01:01", "2006-01-01 12:01:01");
844
833
insert into t1 values ("2006-01-02", "12:01:02", "2006-01-02 12:01:02");