=DATEPART
The DATEPART function extracts a specific numeric component from a given date or datetime value. Useful for reporting, scheduling, and date-based calculations.
Syntax
Section titled “Syntax”=DATEPART(DatePart; DateValue)Parameters
Section titled “Parameters”-
DatePart
-
The part of the date to extract. Valid options include:
-
year – the year of the date
-
weekday – the day of the week (1 = Sunday, 7 = Saturday)
-
yearday – the day of the year (1–365/366)
-
monthweek – the week of the month
-
yearweek – the week of the year
-
month – the month number (1–12)
-
day – the day of the month (1–31)
-
hour – the hour component (0–23)
-
minute – the minute component (0–59)
-
second – the second component (0–59)
-
-
-
DateValue
- The date or datetime value from which the numeric part is extracted.
How It Works
Section titled “How It Works”-
Returns the numeric value corresponding to the specified DatePart of the given date.
-
Can be used in calculations, conditional logic, and reporting workflows.
Usage Notes
Section titled “Usage Notes”-
Ensure the date is in a valid format (e.g., YYYY-MM-DD).
-
Weekday numbering typically starts at 1 (Sunday) and ends at 7 (Saturday).
-
Formula functions are case sensitive and must be in all caps.
Example
Section titled “Example”=DATEPART(weekday; 2023-05-24)- Returns: 4 (Wednesday)
Keywords
Section titled “Keywords”DATEPART, extract date component, day of week, month, year, day, hour, minute, second, week of month, week of year, yearday, numeric date part, formula function, workflow calculations