> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cfo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Work with dates

Date references let formulas move through time, group dates, and calculate period boundaries.

## Use the table's granularity

Write Date with the grain used by the formula:

```text theme={null}
Date.Month
Date.Quarter
Date.Year
```

Supported grains are Day, Week, Month, Quarter, Half, and Year.

## Reference a nearby period

The compact lookup uses the formula's current Date grain:

```text theme={null}
Revenue[[-1]]
```

At monthly grain, this reads Revenue from the previous month. A positive value moves forward.

For an explicit shift, use `offset`:

```text theme={null}
offset(Date.Month, -1, "month")
```

Supported units are day, week, month, quarter, half, and year.

## Select a fixed period

```text theme={null}
Revenue[Date.Month: "2026-01"]
Revenue[Date.Quarter: "2026-Q1"]
Revenue[Date.Year: "2026"]
```

## Read part of a date

```text theme={null}
year(Date.Month)
month(Date.Month)
quarter(Date.Month)
half(Date.Month)
```

Week functions include `weekday`, `weeknum`, and `isoweeknum`.

## Find a period boundary

```text theme={null}
startofmonth(Date.Month)
startofquarter(Date.Month)
eomonth(Date.Month, 0)
```

## Calculate between dates

```text theme={null}
datedif(`Start Date`, Date.Month, "M")
```

`datedif` uses Excel-style unit codes such as `Y`, `M`, and `D`.

## Build a date

```text theme={null}
date(year(Date.Month), 12, 31)
```

## Formula periods

Actuals and Forecast also depend on Date. A formula assigned to a Formula period must include Date in its scope.
