> For the complete documentation index, see [llms.txt](https://docs.rasgoml.com/rasgo-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rasgoml.com/rasgo-docs/rasgo-0.1/all-transforms/datespine.md).

# Datespine

This transform generates a date spine for your date index, which can replace your date index column for modeling.

All intervals are considered to be start-inclusive and end-exclusive, or `[start, end]`. The join with the date spine will be an outer join such that all intervals are present and all data that does not fall into one of those intervals is excluded.

If start\_timestamp or end\_timestamp are left blank, they will be automatically generated as the min or max timestamp in the 'date\_col' column.

It's essentially:

```
SELECT user_table.*, intervals.*
FROM intervals
  LEFT JOIN user_table
  ON ...
```

## Parameters

| Name             | Type       | Description                                                                                                                                                                         | Is Optional |
| ---------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| date\_col        | column     | The column used to create intervals. This must be a datetime column.                                                                                                                |             |
| interval\_type   | date\_part | A valid SQL datepart to slice the date\_col. For interval types, see [this Snowflake doc.](https://docs.snowflake.com/en/sql-reference/data-types-datetime.html#interval-constants) |             |
| start\_timestamp | timestamp  | The timestamp to start calculating from; this will be included in the output set; this timestamp will have no timezone                                                              | True        |
| end\_timestamp   | timestamp  | The timestamp to calculate to; this will be included in the output set; this timestamp will have no timezone                                                                        | True        |

## Example

```python
ds = rasgo.get.dataset(74)

ds2 = ds.datespine(
    date_col='ORDERDATE',
    start_timestamp='2017-01-01',
    end_timestamp='2020-01-01',
    interval_type='month'
)
ds2.preview()

```

## Source Code

{% embed url="<https://github.com/rasgointelligence/RasgoTransforms/blob/main/rasgotransforms/rasgotransforms/transforms/datespine/snowflake/datespine.sql>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.rasgoml.com/rasgo-docs/rasgo-0.1/all-transforms/datespine.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
