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