In this article
Examples of functions to add periods, get specific date parts, test date ranges, and evaluate if a date is within a specific period.
| GetDate() | Date/time | Current date and time |
| DateOf(d) | Date/time | Returns date part of the input date/time value by setting time part to zero |
| Year(d) | Integer | Year part of the specified date/time value |
| Month(d) | Integer | Month part of the specified date/time value |
| Quarter(d) | Integer | Quarter number of the specified date/time value |
| Day(d), (Alias: DayOfMonth) | Integer | Day part of the specified date/time value |
| DayOfWeek(d) | Integer | Day of week for the specified date/time |
| Hour(d) | Integer | Hour part of the specified date/time value |
| Minute(d) | Integer | Minute part of the specified date/time value |
| Second(d) | Integer | Second part of the specified date/time value |
| Millisecond(d) | Integer | Millisecond part of the specified date/time value |
| Week(d) | Integer | Week part of the specified date/time value *) |
| ShiftedYear(d) | Integer | Year part of the specified date/time value taking into account week rule *) |
| ShiftedQuarter(d) | Integer | Quarter number of the specified date/time value taking into account week rule *) |
| CalendarMonth(d) | Integer | Encoded calendar year and month as an integer value (YYYYMM) |
| CalendarQuarter(d) | Integer | Encoded calendar year and quarteras an integer value (YYYYQQ) |
| CalendarWeek(d) | Integer | Encoded calendar year (shifted) and week as an integer value (YYYYWW) |
| CalendarDate(d) | Integer | Encoded calendar year, month and day as an integer value (YYYYMMDD) |
| Date(d) | Integer | Similar to CalendarDate but always uses standard (Gregorian) calendar. If current calendar is the standard one both functions are the same |
AddYear(d,n) AddQuarter(d,n) AddMonth(d,n) AddFullWeek(d,n) **) AddDay(d,n) AddHour(d,n) AddMinute(d,n) | Date/time | Add the specified number of periods to the date taking into account calendar rules. |
DiffYear(startdate, enddate) DiffQuarter(startdate, enddate) DiffMonth(startdate, enddate) DiffFullWeek(startdate, enddate) **) DiffDay(startdate, enddate) DiffHour(startdate, enddate) DiffMinute(startdate, enddate) | Integer | Return the number of period boundaries crossed by the specified date range |
InYear(date, from, to, baseDate) InQuarter(date, from, to, baseDate) InMonth(date, from, to, baseDate) InFullWeek(date, from ,to ,baseDate) **) InDay(date, from, to, baseDate) InHour(date, from, to, baseDate) | Boolean | Evaluate to true if the specified date is within the specified range of periods. from and to arguments define the number of periods relative to the baseDate. The range always covers whole calendar periods. BaseDate is optional, defaults to current date. In the latter case the functions define rolling time periods. InPeriod(date, from, to, baseDate) is equivalent to Between(DiffPeriod(baseDate, date), from, to) |
YearToDate(d) QuarterToDate(d) MonthToDate(d) FullWeekToDate(d) **) DayToDate(d) HourToDate(d) | Boolean | Evaluate to true if the specified date is within the specified current period and is less than current date. PeriodToDate(date) is equivalent to date <= GetDate() AND DiffPeriod(date, GetDate()) = 0 |
| DateBetween(d, lower, upper) | Boolean | Tests whether a date specified in the first argument is within a range defined by second and third arguments. Both boundaries are expected to be defined as date constants. Time portions of all aguments are ignored and only dates are taken into account. Thus both lower and upper dates are fully included regardless of the time. |
** FullWeekXX functions do not use week rules and always consider a week to be 7 day long. However they take into account first week day where appropriate.