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