Update ooo320-m1
[ooovba.git] / connectivity / source / inc / file / FDateFunctions.hxx
bloba02cfac29c2d68f499b148e31ee430f2d4147a5d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FDateFunctions.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CONNECTIVITY_FILE_FDATEFUNCTIONS_HXX_
32 #define _CONNECTIVITY_FILE_FDATEFUNCTIONS_HXX_
34 #include "file/fcode.hxx"
35 #include "file/filedllapi.hxx"
37 namespace connectivity
39 class OSQLParseNode;
40 namespace file
42 /** DAYOFWEEK(date)
43 Returns the weekday index for date (1 = Sunday, 2 = Monday, ... 7 = Saturday). These index values correspond to the ODBC standard.
45 > SELECT DAYOFWEEK('1998-02-03');
46 -> 3
48 class OOp_DayOfWeek : public OUnaryOperator
50 protected:
51 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
54 /** DAYOFMONTH(date)
55 Returns the day of the month for date, in the range 1 to 31:
57 > SELECT DAYOFMONTH('1998-02-03');
58 -> 3
60 class OOp_DayOfMonth : public OUnaryOperator
62 protected:
63 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
66 /** DAYOFYEAR(date)
67 Returns the day of the year for date, in the range 1 to 366:
69 > SELECT DAYOFYEAR('1998-02-03');
70 -> 34
73 class OOp_DayOfYear : public OUnaryOperator
75 protected:
76 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
79 /** MONTH(date)
80 Returns the month for date, in the range 1 to 12:
82 > SELECT MONTH('1998-02-03');
83 -> 2
85 class OOp_Month : public OUnaryOperator
87 protected:
88 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
91 /** DAYNAME(date)
92 Returns the name of the weekday for date:
94 > SELECT DAYNAME('1998-02-05');
95 -> 'Thursday'
98 class OOp_DayName : public OUnaryOperator
100 protected:
101 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
104 /** MONTHNAME(date)
105 Returns the name of the month for date:
107 > SELECT MONTHNAME('1998-02-05');
108 -> 'February'
111 class OOp_MonthName : public OUnaryOperator
113 protected:
114 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
117 /** QUARTER(date)
118 Returns the quarter of the year for date, in the range 1 to 4:
120 > SELECT QUARTER('98-04-01');
121 -> 2
124 class OOp_Quarter : public OUnaryOperator
126 protected:
127 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
130 /** WEEK(date)
131 WEEK(date,first)
132 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:
133 Value Meaning
134 0 Week starts on Sunday and return value is in range 0-53
135 1 Week starts on Monday and return value is in range 0-53
136 2 Week starts on Sunday and return value is in range 1-53
137 3 Week starts on Monday and return value is in range 1-53 (ISO 8601)
139 > SELECT WEEK('1998-02-20');
140 -> 7
141 > SELECT WEEK('1998-02-20',0);
142 -> 7
143 > SELECT WEEK('1998-02-20',1);
144 -> 8
145 > SELECT WEEK('1998-12-31',1);
146 -> 53
149 class OOp_Week : public ONthOperator
151 protected:
152 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
155 /** YEAR(date)
156 Returns the year for date, in the range 1000 to 9999:
158 > SELECT YEAR('98-02-03');
159 -> 1998
161 class OOp_Year : public OUnaryOperator
163 protected:
164 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
167 /** HOUR(time)
168 Returns the hour for time, in the range 0 to 23:
170 > SELECT HOUR('10:05:03');
171 -> 10
173 class OOp_Hour : public OUnaryOperator
175 protected:
176 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
179 /** MINUTE(time)
180 Returns the minute for time, in the range 0 to 59:
182 > SELECT MINUTE('98-02-03 10:05:03');
183 -> 5
186 class OOp_Minute : public OUnaryOperator
188 protected:
189 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
192 /** SECOND(time)
193 Returns the second for time, in the range 0 to 59:
195 > SELECT SECOND('10:05:03');
196 -> 3
198 class OOp_Second : public OUnaryOperator
200 protected:
201 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
204 /** CURDATE()
205 CURRENT_DATE
206 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:
208 > SELECT CURDATE();
209 -> '1997-12-15'
211 class OOp_CurDate : public ONthOperator
213 protected:
214 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
217 /** CURTIME()
218 CURRENT_TIME
219 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:
221 > SELECT CURTIME();
222 -> '23:50:26'
224 class OOp_CurTime : public ONthOperator
226 protected:
227 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
230 /** NOW()
231 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:
233 > SELECT NOW();
234 -> '1997-12-15 23:50:26'
236 class OOp_Now : public ONthOperator
238 protected:
239 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
244 #endif // _CONNECTIVITY_FILE_FCODE_HXX_