name: op-attr-date-part
description: Extract a calendar component (year, month, day, year_month, ..., hour, iso_weekday) from a date or datetime field.
kind: operator
category: ATTR
operator: ATTR_DATE_PART
type: reference
applies_to: process, compose, predict
examples_tags: [time-series, feature-engineering, streaming-friendly]
Use when
Adds a calendar part of a date or datetime field to every row, such as the year, the month, a year-month like 202403 or the hour.
Questions it answers:
- Which month of the year does each order fall in, so seasons can be compared across years?
- What year-month label should each response carry for a monthly breakdown?
Use something else:
GROUP_DATEwhen you only want rows grouped by day, week, month or year.
Params
| Name | Type | Default | Description |
|---|---|---|---|
part | enum | (required) | day, hour, iso_weekday, month, month_day, year, year_month, year_month_day. |
Inputs
field — date or datetime (a schema field). label — derived field name; default ATTR_DATE_PART_<field>.
Output
One f64 integer per record: year = YYYY, month = 1..12, day = 1..31, year_month = YYYYMM, year_month_day = YYYYMMDD, month_day = MMDD, hour = 0..23, iso_weekday = 1..7 (ISO: 1 = Monday, 7 = Sunday; the LOCAL day on a datetime). Null date / datetime source → null (never 0), counted in the aggregation’s n_null.
Contract
- Types (
field):date,datetime; any other scalar type isPULSE_FIELD_TYPE_UNSUPPORTED. - Weight: not read; a weight in force is skipped.
- Streaming: streamable.
Gotchas
- Row-local one-pass — streams cleanly.
- A grouping key (
month_dayfor seasonality,iso_weekdaysorts Monday first) or a post-filterFEATsubstitute. houron adate→PULSE_FIELD_TYPE_UNSUPPORTED; unknownpart→PROCESSING_CONFIG.- Zone-capable: a
datetimereads the LOCAL clock (slottz/tz_field→time_zone_field/time_zone→ cohort default field → default → UTC); nulltz_fieldcell →null. Adateignores zones (explicit refused).
See
pulse_examples_search tags=[time-series]- Skills:
attribute-composition,op-attr-formula,request-envelope(Time zones)