813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
1 |
SELECT YEAR(NULL);
|
2 |
YEAR(NULL)
|
|
3 |
NULL
|
|
4 |
SELECT YEAR();
|
|
5 |
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near ')' at line 1
|
|
6 |
SELECT YEAR(1, 0);
|
|
7 |
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near ' 0)' at line 1
|
|
8 |
SELECT YEAR("xxx");
|
|
9 |
ERROR HY000: Received an invalid datetime value 'xxx'.
|
|
10 |
SELECT YEAR("0000-00-00");
|
|
11 |
ERROR HY000: Received an invalid datetime value '0000-00-00'.
|
|
12 |
SELECT YEAR("0000-01-01");
|
|
13 |
ERROR HY000: Received an invalid datetime value '0000-01-01'.
|
|
14 |
SELECT YEAR("0001-00-01");
|
|
15 |
ERROR HY000: Received an invalid datetime value '0001-00-01'.
|
|
16 |
SELECT YEAR("0001-01-00");
|
|
17 |
ERROR HY000: Received an invalid datetime value '0001-01-00'.
|
|
18 |
SELECT YEAR("2000-02-30");
|
|
19 |
ERROR HY000: Received an invalid datetime value '2000-02-30'.
|
|
20 |
SELECT YEAR("1900-02-29");
|
|
21 |
ERROR HY000: Received an invalid datetime value '1900-02-29'.
|
|
22 |
SELECT YEAR('1976-15-15');
|
|
23 |
ERROR HY000: Received an invalid datetime value '1976-15-15'.
|
|
24 |
SELECT YEAR("2009-01-12");
|
|
25 |
YEAR("2009-01-12")
|
|
26 |
2009
|
|
27 |
SELECT YEAR("70-12-31");
|
|
28 |
YEAR("70-12-31")
|
|
29 |
1970
|
|
30 |
SELECT YEAR("99-12-31");
|
|
31 |
YEAR("99-12-31")
|
|
32 |
1999
|
|
33 |
SELECT YEAR("69-12-31");
|
|
34 |
YEAR("69-12-31")
|
|
35 |
2069
|
|
36 |
SELECT YEAR("0001-12-31");
|
|
37 |
YEAR("0001-12-31")
|
|
38 |
1
|
|
39 |
SELECT YEAR("9999-12-31");
|
|
40 |
YEAR("9999-12-31")
|
|
41 |
9999
|
|
42 |
SELECT YEAR('07/31/2009');
|
|
43 |
YEAR('07/31/2009')
|
|
44 |
2009
|
|
45 |
SELECT YEAR('20090916');
|
|
46 |
YEAR('20090916')
|
|
47 |
2009
|
|
48 |
SELECT YEAR('20090916091528');
|
|
49 |
YEAR('20090916091528')
|
|
50 |
2009
|
|
51 |
SELECT YEAR("20090916091528.000000");
|
|
52 |
YEAR("20090916091528.000000")
|
|
53 |
2009
|
|
54 |
SELECT YEAR('09-09-16');
|
|
55 |
YEAR('09-09-16')
|
|
56 |
2009
|
|
57 |
SELECT YEAR('09.09.16');
|
|
58 |
YEAR('09.09.16')
|
|
59 |
2009
|
|
60 |
SELECT YEAR('09/09/16');
|
|
61 |
YEAR('09/09/16')
|
|
62 |
2009
|
|
63 |
SELECT YEAR('09-09-16');
|
|
64 |
YEAR('09-09-16')
|
|
65 |
2009
|
|
66 |
SELECT YEAR('09-9-2');
|
|
67 |
YEAR('09-9-2')
|
|
68 |
2009
|
|
69 |
SELECT YEAR(20090916);
|
|
70 |
YEAR(20090916)
|
|
71 |
2009
|
|
72 |
SELECT YEAR(20090916091528);
|
|
73 |
YEAR(20090916091528)
|
|
74 |
2009
|
|
813.1.19
by Jay Pipes
To remain in compatibility with MySQL, added ability to interpret |
75 |
SELECT YEAR(20090916091528.000001);
|
76 |
YEAR(20090916091528.000001)
|
|
77 |
2009
|
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
78 |
USE test;
|
79 |
DROP TABLE IF EXISTS t1;
|
|
80 |
CREATE TABLE t1 (
|
|
81 |
int_fld INT NOT NULL
|
|
82 |
, date_fld DATE NOT NULL
|
|
83 |
, datetime_fld DATETIME NOT NULL
|
|
84 |
, timestamp_fld TIMESTAMP NOT NULL
|
|
85 |
, char_fld CHAR(22) NOT NULL
|
|
86 |
, varchar_fld VARCHAR(22) NOT NULL
|
|
87 |
, text_fld TEXT NOT NULL
|
|
88 |
, blob_fld BLOB NOT NULL
|
|
89 |
);
|
|
90 |
INSERT INTO t1 VALUES (
|
|
91 |
20071130
|
|
92 |
, "2007-11-30"
|
|
93 |
, "2007-11-30 16:30:19"
|
|
94 |
, "2007-11-30T16:30:19"
|
|
95 |
, "2007-11-30 16:30:19"
|
|
96 |
, "2007-11-30 16:30:19"
|
|
97 |
, "2007-11-30T16:30:19"
|
|
98 |
, "2007-11-30T16:30:19"
|
|
99 |
);
|
|
100 |
SELECT YEAR(int_fld) FROM t1;
|
|
101 |
YEAR(int_fld)
|
|
102 |
2007
|
|
103 |
SELECT YEAR(date_fld) FROM t1;
|
|
104 |
YEAR(date_fld)
|
|
105 |
2007
|
|
106 |
SELECT YEAR(datetime_fld) FROM t1;
|
|
107 |
YEAR(datetime_fld)
|
|
108 |
2007
|
|
109 |
SELECT YEAR(timestamp_fld) FROM t1;
|
|
110 |
YEAR(timestamp_fld)
|
|
111 |
2007
|
|
112 |
SELECT YEAR(char_fld) FROM t1;
|
|
113 |
YEAR(char_fld)
|
|
114 |
2007
|
|
115 |
SELECT YEAR(varchar_fld) FROM t1;
|
|
116 |
YEAR(varchar_fld)
|
|
117 |
2007
|
|
118 |
SELECT YEAR(text_fld) FROM t1;
|
|
119 |
YEAR(text_fld)
|
|
120 |
2007
|
|
121 |
SELECT YEAR(blob_fld) FROM t1;
|
|
122 |
YEAR(blob_fld)
|
|
123 |
2007
|
|
124 |
DROP TABLE t1;
|