2
# Tests for the DAYOFMONTH() function
4
# The Drizzle DAYOFMONTH() function differs from the MySQL DAYOFMONTH()
5
# function in these ways:
7
# * Does not accept invalid parameters. This results in an error
11
# DAYOFMONTH() on a NULL should produce
13
SELECT DAYOFMONTH(NULL);
16
# Test improper argument list
19
--error 1582 # Wrong parameter count...
21
--error 1582 # Wrong parameter count...
22
SELECT DAYOFMONTH(1, 0);
25
# Test invalid dates passed to DAYOFMONTH
26
# produce an error, not a NULL or anything
30
SELECT DAYOFMONTH("xxx");
34
SELECT DAYOFMONTH("0000-00-00"); # No 0000-00-00 dates!...
36
SELECT DAYOFMONTH("0000-01-01"); # No zero year parts
38
SELECT DAYOFMONTH("0001-00-01"); # No zero month parts
40
SELECT DAYOFMONTH("0001-01-00"); # No zero day parts
42
SELECT DAYOFMONTH("2000-02-30"); # No Feb 30th!
44
SELECT DAYOFMONTH("1900-02-29"); # Not a leap DAYOFMONTH since not divisible evenly by 400...
46
SELECT DAYOFMONTH('1976-15-15'); # No 15th month!
48
# A good date, which should output 1
49
SELECT DAYOFMONTH("2009-01-12");
51
# A good date, which should output 31 - Test of 2 digit DAYOFMONTH conversion and proper day...
52
SELECT DAYOFMONTH("70-12-31");
54
# A good date, which should output 329 - Test of 2 digit DAYOFMONTH conversion and proper day in a leap year...
55
SELECT DAYOFMONTH("00-02-29");
57
# A good date, which should output 31
58
SELECT DAYOFMONTH("0001-12-31");
60
# A good date in the common USA format, should output 31
61
SELECT DAYOFMONTH('07/31/2009');
64
# Tests for alternate DATETIME syntaxes
65
# in string and numeric formats. All should
68
SELECT DAYOFMONTH('20090916');
69
SELECT DAYOFMONTH('20090916091528');
70
SELECT DAYOFMONTH("20090916091528.000000");
71
SELECT DAYOFMONTH('09-09-16');
72
SELECT DAYOFMONTH('09.09.16');
73
SELECT DAYOFMONTH('09/09/16');
74
SELECT DAYOFMONTH('09-09-16');
75
SELECT DAYOFMONTH('09-9-2');
76
SELECT DAYOFMONTH(20090916);
77
SELECT DAYOFMONTH(20090916091528);
78
--error 1686 # Don't yet support DOUBLE -> DATETIME.
79
SELECT DAYOFMONTH(20090916091528.000000);
81
# Now test field values of different types
85
DROP TABLE IF EXISTS t1;
89
, date_fld DATE NOT NULL
90
, datetime_fld DATETIME NOT NULL
91
, timestamp_fld TIMESTAMP NOT NULL
92
, char_fld CHAR(22) NOT NULL
93
, varchar_fld VARCHAR(22) NOT NULL
94
, text_fld TEXT NOT NULL
95
, blob_fld BLOB NOT NULL
98
# Should all output 30
99
INSERT INTO t1 VALUES (
102
, "2007-11-30 16:30:19"
103
, "2007-11-30T16:30:19"
104
, "2007-11-30 16:30:19"
105
, "2007-11-30 16:30:19"
106
, "2007-11-30T16:30:19"
107
, "2007-11-30T16:30:19"
110
SELECT DAYOFMONTH(int_fld) FROM t1;
111
SELECT DAYOFMONTH(date_fld) FROM t1;
112
SELECT DAYOFMONTH(datetime_fld) FROM t1;
113
SELECT DAYOFMONTH(timestamp_fld) FROM t1;
114
SELECT DAYOFMONTH(char_fld) FROM t1;
115
SELECT DAYOFMONTH(varchar_fld) FROM t1;
116
SELECT DAYOFMONTH(text_fld) FROM t1;
117
SELECT DAYOFMONTH(blob_fld) FROM t1;