#date
DateCreates a date value from year, month, and day components.
Syntax
#date(year as number, month as number, day as number) as dateParameters
| Name | Type | Required | Description |
|---|---|---|---|
year | number | Yes | The year component (e.g. 2024). |
month | number | Yes | The month component (1–12). |
day | number | Yes | The day component (1–31, depending on month). |
Return Value
date — A date value representing the specified calendar date.
Remarks
#date is M's literal constructor for creating date values. It is the canonical way to write a specific calendar date inline in M code.
The arguments must be valid calendar values — out-of-range values (e.g. month 13, day 32) produce an error at evaluation time.
#date produces a value of type date only (no time component). To construct a datetime, use #datetime. To convert a date to a datetime, use DateTime.From.
Examples
Example 1: Create a date literal
#date(2024, 3, 15)Result
Result | |
|---|---|
| 1 | 3/15/2024 |
Example 2: Use a date literal in arithmetic
let
start = #date(2024, 1, 1),
end = #date(2024, 12, 31),
days = Duration.Days(end - start)
in
daysResult
Result | |
|---|---|
| 1 | 365 |
Example 3: Add days to a date literal
#date(2024, 1, 1) + #duration(30, 0, 0, 0)Result
Result | |
|---|---|
| 1 | 1/31/2024 |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks