Returns a number that specifies a given part of a given date.
Overloads
Parameters
| IntervalType value | Description |
|---|---|
| Yyyy | Extracts the year |
| Q | Quarter (the result is 1, 2, 3 or 4) |
| M | Month (the result is from 1 to 12) |
| Y | Day of year (1 to 365 or 366 in a leap year) |
| D | Day part of the date (1 to 31) Year |
| W | Day of week (1 to 7 with the result depending on firstDayOfWeek) |
| Ww | Week of year (1 to 53 with firstDayOfWeek and firstWeekOfYear determining the exact days of the first calendar week of the year) |
| H | Extracts the hour part of the given DateTime (0 to 23) |
| N | Minute part (0 to 59) |
| S | Second part (0 to 59) |
| Constant | Description |
|---|---|
| jrUseSystem | 0 (Use the current system date) |
| jrSunday | 1 |
| jrMonday | 2 |
| jrTuesday | 3 |
| jrWednesday | 4 |
| jrThursday | 5 |
| jrFriday | 6 |
| jrSaturday | 7 |
| Constant | Value | Description |
|---|---|---|
| jrUseSystem | 0 | Start with week in which system date occurs |
| jrFirstJan1 | 1 | Start with week in which January 1 occurs (default) |
| jrFirstFourDays | 2 | Start with the first week that has at least four days in the new year |
| jrFirstFullWeek | 3 | Start with first full week of the year |
Examples
DatePart("d", ToDateTime(1999,8,15)) - Returns 15.DatePart("m", ToDateTime(1999,8,15)) - Returns 8.DatePart("n", ToDateTime(1999,8,15,10,35,0)) - Returns 35.DatePart("q", ToDateTime(1999, 9,29)) - Returns 3 since September 29 is in the third quarter of the year.DatePart("ww", ToDateTime(1997, 9,14)) - Returns 38 since 1997-9-14 is in the 38th week of 1997.Notes: