~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to docs/functions/extract_date.rst

  • Committer: Lee Bieber
  • Date: 2011-02-11 20:30:05 UTC
  • mfrom: (2157.1.3 build)
  • Revision ID: kalebral@gmail.com-20110211203005-757o1y2yf78dxzqr
Merge Stewart - 716848: drizzleimport displays wrong program_name
Merge Stewart - update README file
Merge Andrew and Joe - Exposes the InnoDB SYS_REPLICATION_LOG to data_dictionary so that it is fast and fixes many issues we have been having

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 
14
14
The following field names are available:
15
15
 
16
 
**day**
17
 
 
18
 
.. code-block:: mysql
 
16
**day** ::
19
17
        
20
18
        SELECT EXTRACT(DAY FROM TIMESTAMP '2001-02-16 20:38:40');
21
19
 
23
21
 
24
22
*Result: 16*
25
23
 
26
 
**decade**
27
 
 
28
 
.. code-block:: mysql
 
24
**decade** ::
29
25
        
30
26
        SELECT EXTRACT(DECADE FROM TIMESTAMP '2001-02-16 20:38:40');
31
27
 
33
29
 
34
30
*Result: 200*
35
31
 
36
 
**dow**
37
 
 
38
 
.. code-block:: mysql
 
32
**dow** ::
39
33
        
40
34
        SELECT EXTRACT(DOW FROM TIMESTAMP '2001-02-16 20:38:40');
41
35
 
43
37
 
44
38
*Result: 5*
45
39
 
46
 
**doy**
47
 
 
48
 
.. code-block:: mysql
 
40
**doy** ::
49
41
 
50
42
        SELECT EXTRACT(DOY FROM TIMESTAMP '2001-02-16 20:38:40');
51
43
 
53
45
 
54
46
*Result: 47*
55
47
 
56
 
**hour**
57
 
 
58
 
.. code-block:: mysql
 
48
**hour** ::
59
49
 
60
50
        SELECT EXTRACT(HOUR FROM TIMESTAMP '2001-02-16 20:38:40');
61
51
 
63
53
 
64
54
*Result: 20*
65
55
 
66
 
**microseconds**
67
 
 
68
 
.. code-block:: mysql
 
56
**microseconds** ::
69
57
 
70
58
        SELECT EXTRACT(MICROSECONDS FROM TIME '17:12:28.5');
71
59
 
73
61
 
74
62
*Result: 28500000*
75
63
 
76
 
**minute**
77
 
 
78
 
.. code-block:: mysql
 
64
**minute** ::
79
65
 
80
66
        SELECT EXTRACT(MINUTE FROM TIMESTAMP '2001-02-16 20:38:40');
81
67
 
86
72
**month**
87
73
 
88
74
For timestamp values, the number of the month within the year (1 - 12). 
89
 
For interval values, the number of months (0 - 11).
90
 
 
91
 
.. code-block:: mysql
 
75
For interval values, the number of months (0 - 11). ::
92
76
 
93
77
        SELECT EXTRACT(MONTH FROM TIMESTAMP '2010-12-29 08:45:27');
94
78
 
95
 
*Result: 12*
96
 
 
97
 
.. code-block:: mysql
 
79
*Result: 12* ::
98
80
 
99
81
        SELECT EXTRACT(MONTH FROM INTERVAL '3 years 4 months');
100
82
 
101
 
*Result: 4*
102
 
 
103
 
.. code-block:: mysql
 
83
*Result: 4* ::
104
84
 
105
85
        SELECT EXTRACT(MONTH FROM INTERVAL '3 years 13 months');
106
86
 
107
87
*Result: 1*
108
88
 
109
 
**quarter**
110
 
 
111
 
.. code-block:: mysql
 
89
**quarter** ::
112
90
 
113
91
        SELECT EXTRACT(QUARTER FROM TIMESTAMP '2010-12-29 08:45:27');
114
92
 
116
94
        
117
95
*Result: 4*
118
96
 
119
 
**second**
120
 
 
121
 
.. code-block:: mysql
 
97
**second** ::
122
98
 
123
99
        SELECT EXTRACT(SECOND FROM TIMESTAMP '2010-12-29 08:45:27');
124
100
 
125
101
The seconds field, including fractional parts (0 - 59)
126
102
        
127
 
*Result: 27*
128
 
 
129
 
.. code-block:: mysql
 
103
*Result: 27* ::
130
104
 
131
105
        SELECT EXTRACT(SECOND FROM TIME '08:15:22.5');
132
106
 
142
116
 
143
117
ISO 8601:1988 means that if the week containing January 1 has four or more days in the new year, then it is week 1; otherwise it is the last week of the previous year, and the next week is week 1. The ISO-8601 week starts on Monday.
144
118
 
145
 
It's possible for early January dates to be part of the 52nd or 53rd week of the previous year. For example, 2011-01-01 was part of the 52nd week of year 2010.
146
 
 
147
 
.. code-block:: mysql
 
119
It's possible for early January dates to be part of the 52nd or 53rd week of the previous year. For example, 2011-01-01 was part of the 52nd week of year 2010. ::
148
120
 
149
121
        SELECT EXTRACT(WEEK FROM TIMESTAMP '2010-01-25 12:44:06');
150
122
 
151
123
*Result: 4*
152
124
 
153
 
**year**
154
 
 
155
 
.. code-block:: mysql
 
125
**year** ::
156
126
 
157
127
        SELECT EXTRACT(YEAR FROM TIMESTAMP '2009-02-16 20:38:40');
158
128
 
159
129
*Result: 2009*
160
130
 
161
 
The valid field names for date_part are the same as for extract.
162
 
 
163
 
.. code-block:: mysql
 
131
The valid field names for date_part are the same as for extract. ::
164
132
 
165
133
        SELECT date_part('day', TIMESTAMP '2010-07-16 10:12:05');
166
134
 
167
 
*Result: 16*
168
 
 
169
 
.. code-block:: mysql
 
135
*Result: 16* ::
170
136
 
171
137
        SELECT date_part('hour', INTERVAL '5 hours 12 minutes');
172
138