diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 5eb21c40a3e..ee4fa074477 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -330,3 +330,10 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: Note 1003 select high_priority makedate(1997,1) AS `makedate(1997,1)`,addtime(_latin1'31.12.97 11.59.59.999999 PM',_latin1'31.12.97 11.59.59.999999 PM') AS `addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002")`,subtime(_latin1'31.12.97 11.59.59.999999 PM',_latin1'31.12.97 11.59.59.999999 PM') AS `subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002")`,timediff(_latin1'01.01.97 11:59:59.000001 PM',_latin1'31.12.95 11:59:59.000002 PM') AS `timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM")`,cast(str_to_date(_latin1'15-01-2001 12:59:59',_latin1'%d-%m-%Y %H:%i:%S') as time) AS `cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME)`,maketime(23,11,12) AS `maketime(23,11,12)`,microsecond(_latin1'1997-12-31 23:59:59.000001') AS `microsecond("1997-12-31 23:59:59.000001")` +create table t1 (d date); +insert into t1 values ('2004-07-14'),('2005-07-14'); +select date_format(d,"%d") from t1 order by 1; +date_format(d,"%d") +14 +14 +drop table t1; diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index d9219d3ac2e..7b88c0ecf72 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -200,3 +200,12 @@ select get_format(DATE, 'TEST') as a; select str_to_date('15-01-2001 12:59:59', GET_FORMAT(DATE,'USA')); explain extended select makedate(1997,1), addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM"),cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME), maketime(23,11,12),microsecond("1997-12-31 23:59:59.000001"); + +# +# Test of date_format() +# + +create table t1 (d date); +insert into t1 values ('2004-07-14'),('2005-07-14'); +select date_format(d,"%d") from t1 order by 1; +drop table t1; diff --git a/sql/field.cc b/sql/field.cc index 9b8e386fdc5..23f6e1232b6 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3757,7 +3757,7 @@ bool Field_newdate::get_date(TIME *ltime,uint fuzzydate) ltime->month= (tmp >> 5) & 15; ltime->year= (tmp >> 9); ltime->time_type=TIMESTAMP_DATE; - ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0; + ltime->hour= ltime->minute= ltime->second= ltime->second_part= ltime->neg= 0; return (!fuzzydate && (!ltime->month || !ltime->day)) ? 1 : 0; }