xref: /AOO41X/main/connectivity/source/inc/file/FDateFunctions.hxx (revision caf5cd79edad04a48dcaf209068b3b89eae4622e)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _CONNECTIVITY_FILE_FDATEFUNCTIONS_HXX_
25 #define _CONNECTIVITY_FILE_FDATEFUNCTIONS_HXX_
26 
27 #include "file/fcode.hxx"
28 #include "file/filedllapi.hxx"
29 
30 namespace connectivity
31 {
32     class OSQLParseNode;
33     namespace file
34     {
35         /** DAYOFWEEK(date)
36             Returns the weekday index for date (1 = Sunday, 2 = Monday, ... 7 = Saturday). These index values correspond to the ODBC standard.
37 
38         > SELECT DAYOFWEEK('1998-02-03');
39                 -> 3
40         */
41         class OOp_DayOfWeek : public OUnaryOperator
42         {
43         protected:
44             virtual ORowSetValue operate(const ORowSetValue& lhs) const;
45         };
46 
47         /** DAYOFMONTH(date)
48             Returns the day of the month for date, in the range 1 to 31:
49 
50         > SELECT DAYOFMONTH('1998-02-03');
51                 -> 3
52         */
53         class OOp_DayOfMonth : public OUnaryOperator
54         {
55         protected:
56             virtual ORowSetValue operate(const ORowSetValue& lhs) const;
57         };
58 
59         /** DAYOFYEAR(date)
60             Returns the day of the year for date, in the range 1 to 366:
61 
62         > SELECT DAYOFYEAR('1998-02-03');
63                 -> 34
64 
65         */
66         class OOp_DayOfYear : public OUnaryOperator
67         {
68         protected:
69             virtual ORowSetValue operate(const ORowSetValue& lhs) const;
70         };
71 
72         /** MONTH(date)
73             Returns the month for date, in the range 1 to 12:
74 
75         > SELECT MONTH('1998-02-03');
76                 -> 2
77         */
78         class OOp_Month : public OUnaryOperator
79         {
80         protected:
81             virtual ORowSetValue operate(const ORowSetValue& lhs) const;
82         };
83 
84         /** DAYNAME(date)
85             Returns the name of the weekday for date:
86 
87         > SELECT DAYNAME('1998-02-05');
88                 -> 'Thursday'
89 
90         */
91         class OOp_DayName : public OUnaryOperator
92         {
93         protected:
94             virtual ORowSetValue operate(const ORowSetValue& lhs) const;
95         };
96 
97         /** MONTHNAME(date)
98             Returns the name of the month for date:
99 
100         > SELECT MONTHNAME('1998-02-05');
101                 -> 'February'
102 
103         */
104         class OOp_MonthName : public OUnaryOperator
105         {
106         protected:
107             virtual ORowSetValue operate(const ORowSetValue& lhs) const;
108         };
109 
110         /** QUARTER(date)
111             Returns the quarter of the year for date, in the range 1 to 4:
112 
113         > SELECT QUARTER('98-04-01');
114                 -> 2
115 
116         */
117         class OOp_Quarter : public OUnaryOperator
118         {
119         protected:
120             virtual ORowSetValue operate(const ORowSetValue& lhs) const;
121         };
122 
123         /** WEEK(date)
124             WEEK(date,first)
125                 With a single argument, returns the week for date, in the range 0 to 53 (yes, there may be the beginnings of a week 53), for locations where Sunday is the first day of the week. The two-argument form of WEEK() allows you to specify whether the week starts on Sunday or Monday and whether the return value should be in the range 0-53 or 1-52. Here is a table for how the second argument works:
126                 Value   Meaning
127                 0   Week starts on Sunday and return value is in range 0-53
128                 1   Week starts on Monday and return value is in range 0-53
129                 2   Week starts on Sunday and return value is in range 1-53
130                 3   Week starts on Monday and return value is in range 1-53 (ISO 8601)
131 
132             > SELECT WEEK('1998-02-20');
133                     -> 7
134             > SELECT WEEK('1998-02-20',0);
135                     -> 7
136             > SELECT WEEK('1998-02-20',1);
137                     -> 8
138             > SELECT WEEK('1998-12-31',1);
139                     -> 53
140 
141         */
142         class OOp_Week : public ONthOperator
143         {
144         protected:
145             virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
146         };
147 
148         /** YEAR(date)
149             Returns the year for date, in the range 1000 to 9999:
150 
151         > SELECT YEAR('98-02-03');
152                 -> 1998
153         */
154         class OOp_Year : public OUnaryOperator
155         {
156         protected:
157             virtual ORowSetValue operate(const ORowSetValue& lhs) const;
158         };
159 
160         /** HOUR(time)
161             Returns the hour for time, in the range 0 to 23:
162 
163         > SELECT HOUR('10:05:03');
164                 -> 10
165         */
166         class OOp_Hour : public OUnaryOperator
167         {
168         protected:
169             virtual ORowSetValue operate(const ORowSetValue& lhs) const;
170         };
171 
172         /** MINUTE(time)
173             Returns the minute for time, in the range 0 to 59:
174 
175         > SELECT MINUTE('98-02-03 10:05:03');
176                 -> 5
177 
178         */
179         class OOp_Minute : public OUnaryOperator
180         {
181         protected:
182             virtual ORowSetValue operate(const ORowSetValue& lhs) const;
183         };
184 
185         /** SECOND(time)
186             Returns the second for time, in the range 0 to 59:
187 
188         > SELECT SECOND('10:05:03');
189                 -> 3
190         */
191         class OOp_Second : public OUnaryOperator
192         {
193         protected:
194             virtual ORowSetValue operate(const ORowSetValue& lhs) const;
195         };
196 
197         /** CURDATE()
198             CURRENT_DATE
199                 Returns today's date as a value in 'YYYY-MM-DD' or YYYYMMDD format, depending on whether the function is used in a string or numeric context:
200 
201             > SELECT CURDATE();
202                     -> '1997-12-15'
203         */
204         class OOp_CurDate : public ONthOperator
205         {
206         protected:
207             virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
208         };
209 
210         /** CURTIME()
211             CURRENT_TIME
212                 Returns the current time as a value in 'HH:MM:SS' or HHMMSS format, depending on whether the function is used in a string or numeric context:
213 
214             > SELECT CURTIME();
215                     -> '23:50:26'
216         */
217         class OOp_CurTime : public ONthOperator
218         {
219         protected:
220             virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
221         };
222 
223         /** NOW()
224             Returns the current date and time as a value in 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context:
225 
226             > SELECT NOW();
227                     -> '1997-12-15 23:50:26'
228         */
229         class OOp_Now : public ONthOperator
230         {
231         protected:
232             virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
233         };
234     }
235 }
236 
237 #endif // _CONNECTIVITY_FILE_FCODE_HXX_
238 
239