1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _CONNECTIVITY_FILE_FDATEFUNCTIONS_HXX_ 29 #define _CONNECTIVITY_FILE_FDATEFUNCTIONS_HXX_ 30 31 #include "file/fcode.hxx" 32 #include "file/filedllapi.hxx" 33 34 namespace connectivity 35 { 36 class OSQLParseNode; 37 namespace file 38 { 39 /** DAYOFWEEK(date) 40 Returns the weekday index for date (1 = Sunday, 2 = Monday, ... 7 = Saturday). These index values correspond to the ODBC standard. 41 42 > SELECT DAYOFWEEK('1998-02-03'); 43 -> 3 44 */ 45 class OOp_DayOfWeek : public OUnaryOperator 46 { 47 protected: 48 virtual ORowSetValue operate(const ORowSetValue& lhs) const; 49 }; 50 51 /** DAYOFMONTH(date) 52 Returns the day of the month for date, in the range 1 to 31: 53 54 > SELECT DAYOFMONTH('1998-02-03'); 55 -> 3 56 */ 57 class OOp_DayOfMonth : public OUnaryOperator 58 { 59 protected: 60 virtual ORowSetValue operate(const ORowSetValue& lhs) const; 61 }; 62 63 /** DAYOFYEAR(date) 64 Returns the day of the year for date, in the range 1 to 366: 65 66 > SELECT DAYOFYEAR('1998-02-03'); 67 -> 34 68 69 */ 70 class OOp_DayOfYear : public OUnaryOperator 71 { 72 protected: 73 virtual ORowSetValue operate(const ORowSetValue& lhs) const; 74 }; 75 76 /** MONTH(date) 77 Returns the month for date, in the range 1 to 12: 78 79 > SELECT MONTH('1998-02-03'); 80 -> 2 81 */ 82 class OOp_Month : public OUnaryOperator 83 { 84 protected: 85 virtual ORowSetValue operate(const ORowSetValue& lhs) const; 86 }; 87 88 /** DAYNAME(date) 89 Returns the name of the weekday for date: 90 91 > SELECT DAYNAME('1998-02-05'); 92 -> 'Thursday' 93 94 */ 95 class OOp_DayName : public OUnaryOperator 96 { 97 protected: 98 virtual ORowSetValue operate(const ORowSetValue& lhs) const; 99 }; 100 101 /** MONTHNAME(date) 102 Returns the name of the month for date: 103 104 > SELECT MONTHNAME('1998-02-05'); 105 -> 'February' 106 107 */ 108 class OOp_MonthName : public OUnaryOperator 109 { 110 protected: 111 virtual ORowSetValue operate(const ORowSetValue& lhs) const; 112 }; 113 114 /** QUARTER(date) 115 Returns the quarter of the year for date, in the range 1 to 4: 116 117 > SELECT QUARTER('98-04-01'); 118 -> 2 119 120 */ 121 class OOp_Quarter : public OUnaryOperator 122 { 123 protected: 124 virtual ORowSetValue operate(const ORowSetValue& lhs) const; 125 }; 126 127 /** WEEK(date) 128 WEEK(date,first) 129 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: 130 Value Meaning 131 0 Week starts on Sunday and return value is in range 0-53 132 1 Week starts on Monday and return value is in range 0-53 133 2 Week starts on Sunday and return value is in range 1-53 134 3 Week starts on Monday and return value is in range 1-53 (ISO 8601) 135 136 > SELECT WEEK('1998-02-20'); 137 -> 7 138 > SELECT WEEK('1998-02-20',0); 139 -> 7 140 > SELECT WEEK('1998-02-20',1); 141 -> 8 142 > SELECT WEEK('1998-12-31',1); 143 -> 53 144 145 */ 146 class OOp_Week : public ONthOperator 147 { 148 protected: 149 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const; 150 }; 151 152 /** YEAR(date) 153 Returns the year for date, in the range 1000 to 9999: 154 155 > SELECT YEAR('98-02-03'); 156 -> 1998 157 */ 158 class OOp_Year : public OUnaryOperator 159 { 160 protected: 161 virtual ORowSetValue operate(const ORowSetValue& lhs) const; 162 }; 163 164 /** HOUR(time) 165 Returns the hour for time, in the range 0 to 23: 166 167 > SELECT HOUR('10:05:03'); 168 -> 10 169 */ 170 class OOp_Hour : public OUnaryOperator 171 { 172 protected: 173 virtual ORowSetValue operate(const ORowSetValue& lhs) const; 174 }; 175 176 /** MINUTE(time) 177 Returns the minute for time, in the range 0 to 59: 178 179 > SELECT MINUTE('98-02-03 10:05:03'); 180 -> 5 181 182 */ 183 class OOp_Minute : public OUnaryOperator 184 { 185 protected: 186 virtual ORowSetValue operate(const ORowSetValue& lhs) const; 187 }; 188 189 /** SECOND(time) 190 Returns the second for time, in the range 0 to 59: 191 192 > SELECT SECOND('10:05:03'); 193 -> 3 194 */ 195 class OOp_Second : public OUnaryOperator 196 { 197 protected: 198 virtual ORowSetValue operate(const ORowSetValue& lhs) const; 199 }; 200 201 /** CURDATE() 202 CURRENT_DATE 203 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: 204 205 > SELECT CURDATE(); 206 -> '1997-12-15' 207 */ 208 class OOp_CurDate : public ONthOperator 209 { 210 protected: 211 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const; 212 }; 213 214 /** CURTIME() 215 CURRENT_TIME 216 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: 217 218 > SELECT CURTIME(); 219 -> '23:50:26' 220 */ 221 class OOp_CurTime : public ONthOperator 222 { 223 protected: 224 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const; 225 }; 226 227 /** NOW() 228 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: 229 230 > SELECT NOW(); 231 -> '1997-12-15 23:50:26' 232 */ 233 class OOp_Now : public ONthOperator 234 { 235 protected: 236 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const; 237 }; 238 } 239 } 240 241 #endif // _CONNECTIVITY_FILE_FCODE_HXX_ 242 243