1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FDateFunctions.hxx,v $
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
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');
48 class OOp_DayOfWeek
: public OUnaryOperator
51 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
55 Returns the day of the month for date, in the range 1 to 31:
57 > SELECT DAYOFMONTH('1998-02-03');
60 class OOp_DayOfMonth
: public OUnaryOperator
63 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
67 Returns the day of the year for date, in the range 1 to 366:
69 > SELECT DAYOFYEAR('1998-02-03');
73 class OOp_DayOfYear
: public OUnaryOperator
76 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
80 Returns the month for date, in the range 1 to 12:
82 > SELECT MONTH('1998-02-03');
85 class OOp_Month
: public OUnaryOperator
88 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
92 Returns the name of the weekday for date:
94 > SELECT DAYNAME('1998-02-05');
98 class OOp_DayName
: public OUnaryOperator
101 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
105 Returns the name of the month for date:
107 > SELECT MONTHNAME('1998-02-05');
111 class OOp_MonthName
: public OUnaryOperator
114 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
118 Returns the quarter of the year for date, in the range 1 to 4:
120 > SELECT QUARTER('98-04-01');
124 class OOp_Quarter
: public OUnaryOperator
127 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
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:
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');
141 > SELECT WEEK('1998-02-20',0);
143 > SELECT WEEK('1998-02-20',1);
145 > SELECT WEEK('1998-12-31',1);
149 class OOp_Week
: public ONthOperator
152 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const;
156 Returns the year for date, in the range 1000 to 9999:
158 > SELECT YEAR('98-02-03');
161 class OOp_Year
: public OUnaryOperator
164 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
168 Returns the hour for time, in the range 0 to 23:
170 > SELECT HOUR('10:05:03');
173 class OOp_Hour
: public OUnaryOperator
176 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
180 Returns the minute for time, in the range 0 to 59:
182 > SELECT MINUTE('98-02-03 10:05:03');
186 class OOp_Minute
: public OUnaryOperator
189 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
193 Returns the second for time, in the range 0 to 59:
195 > SELECT SECOND('10:05:03');
198 class OOp_Second
: public OUnaryOperator
201 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
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:
211 class OOp_CurDate
: public ONthOperator
214 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const;
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:
224 class OOp_CurTime
: public ONthOperator
227 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const;
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:
234 -> '1997-12-15 23:50:26'
236 class OOp_Now
: public ONthOperator
239 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const;
244 #endif // _CONNECTIVITY_FILE_FCODE_HXX_