1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FDATEFUNCTIONS_HXX
21 #define INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FDATEFUNCTIONS_HXX
23 #include "file/fcode.hxx"
24 #include "file/filedllapi.hxx"
26 namespace connectivity
31 Returns the weekday index for date (1 = Sunday, 2 = Monday, ... 7 = Saturday). These index values correspond to the ODBC standard.
33 > SELECT DAYOFWEEK('1998-02-03');
36 class OOp_DayOfWeek
: public OUnaryOperator
39 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
43 Returns the day of the month for date, in the range 1 to 31:
45 > SELECT DAYOFMONTH('1998-02-03');
48 class OOp_DayOfMonth
: public OUnaryOperator
51 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
55 Returns the day of the year for date, in the range 1 to 366:
57 > SELECT DAYOFYEAR('1998-02-03');
61 class OOp_DayOfYear
: public OUnaryOperator
64 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
68 Returns the month for date, in the range 1 to 12:
70 > SELECT MONTH('1998-02-03');
73 class OOp_Month
: public OUnaryOperator
76 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
80 Returns the name of the weekday for date:
82 > SELECT DAYNAME('1998-02-05');
86 class OOp_DayName
: public OUnaryOperator
89 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
93 Returns the name of the month for date:
95 > SELECT MONTHNAME('1998-02-05');
99 class OOp_MonthName
: public OUnaryOperator
102 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
106 Returns the quarter of the year for date, in the range 1 to 4:
108 > SELECT QUARTER('98-04-01');
112 class OOp_Quarter
: public OUnaryOperator
115 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
120 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:
122 0 Week starts on Sunday and return value is in range 0-53
123 1 Week starts on Monday and return value is in range 0-53
124 2 Week starts on Sunday and return value is in range 1-53
125 3 Week starts on Monday and return value is in range 1-53 (ISO 8601)
127 > SELECT WEEK('1998-02-20');
129 > SELECT WEEK('1998-02-20',0);
131 > SELECT WEEK('1998-02-20',1);
133 > SELECT WEEK('1998-12-31',1);
137 class OOp_Week
: public ONthOperator
140 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const SAL_OVERRIDE
;
144 Returns the year for date, in the range 1000 to 9999:
146 > SELECT YEAR('98-02-03');
149 class OOp_Year
: public OUnaryOperator
152 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
156 Returns the hour for time, in the range 0 to 23:
158 > SELECT HOUR('10:05:03');
161 class OOp_Hour
: public OUnaryOperator
164 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
168 Returns the minute for time, in the range 0 to 59:
170 > SELECT MINUTE('98-02-03 10:05:03');
174 class OOp_Minute
: public OUnaryOperator
177 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
181 Returns the second for time, in the range 0 to 59:
183 > SELECT SECOND('10:05:03');
186 class OOp_Second
: public OUnaryOperator
189 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
194 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:
199 class OOp_CurDate
: public ONthOperator
202 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const SAL_OVERRIDE
;
207 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:
212 class OOp_CurTime
: public ONthOperator
215 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const SAL_OVERRIDE
;
219 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:
222 -> '1997-12-15 23:50:26'
224 class OOp_Now
: public ONthOperator
227 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const SAL_OVERRIDE
;
232 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FDATEFUNCTIONS_HXX
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */