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

# extract_date_component

> Extract a component such as day, week, weekday etc. from a date column. 

The type of the output column depends on the component extracted. Where the component is a name (e.g. of the day of week),
the result will be a categorical column. Otherwise it will be numeric.

## Usage

The following example shows how the step can be used in a recipe.

<Accordion title="Examples" icon="code" defaultOpen="true">
  <Tabs>
    <Tab title="Example 1">
      To extract the number of the month (1..12) from a date column:

      ```stan theme={null}
      extract_date_component(ds.date, {"component": "month"}) -> (ds.month)
      ```
    </Tab>

    <Tab title="Signature">
      General syntax for using the step in a recipe. Shows the inputs and outputs the step is expected to receive and will produce respectively. For futher details see sections below.

      ```stan theme={null}
      extract_date_component(date: date, {
          "param": value,
          ...
      }) -> (component: column)
      ```
    </Tab>
  </Tabs>
</Accordion>

## Inputs & Outputs

The following are the inputs expected by the step and the outputs it produces. These are generally
columns (`ds.first_name`), datasets (`ds` or `ds[["first_name", "last_name"]]`) or models (referenced
by name e.g. `"churn-clf"`).

<Accordion title="Inputs" icon="right-to-bracket">
  <ParamField path="date" type="column[date]" required>
    A column of dates to extract the desired component from.
  </ParamField>
</Accordion>

<Accordion title="Outputs" icon="right-from-bracket">
  <ParamField path="component" type="column" required>
    A numeric or categorical column containing the desired component.
  </ParamField>
</Accordion>

## Configuration

The following parameters can be used to configure the behaviour of the step by including them in
a json object as the last "input" to the step, i.e. `step(..., {"param": "value", ...}) -> (output)`.

<Accordion title="Parameters" defaultOpen="true" icon="sliders">
  <ParamField path="component" type="string" default="day" required>
    The name of the date component to extract.

    Values must be one of the following:

    `date` `day` `day_name` `dayofmonth` `dayofweek` `dayofyear` `hour` `minute` `month` `month_name` `part_of_day` `partofday` `period_of_day` `periodofday` `quarter` `season` `second` `time` `week` `weekday` `weekday_name` `weekofyear` `year`
  </ParamField>

  <ParamField path="tz" type="string" default="UTC">
    The timezone to use when extracting the date component.
    The timezone to use when extracting the date component. If not specified, the timezone of the column metadata will be used.
    If the column metadata does not specify a timezone, UTC will be used.
    The expected format is \[+/-]HH:MM, e.g. +01:00, 02:00, -05:00, +00:00, etc.
  </ParamField>
</Accordion>
