# Date Truncation

Truncates a date value or a timestamp to a specific part.

For a date or a timestamp, you can truncate to the year, month, or day.

For a timestamp, you can also truncate to the hour, minute, or second.

## Characteristics <a href="#date-truncation-characteristics" id="date-truncation-characteristics"></a>

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top"><strong>Consistency</strong></td><td valign="top">No, cannot be made consistent.</td></tr><tr><td valign="top"><strong>Linking</strong></td><td valign="top">No, cannot be linked.</td></tr><tr><td valign="top"><strong>Differential privacy</strong></td><td valign="top">No</td></tr><tr><td valign="top"><strong>Data-free</strong></td><td valign="top">No</td></tr><tr><td valign="top"><strong>Allowed for primary keys</strong></td><td valign="top">No</td></tr><tr><td valign="top"><strong>Allowed for unique columns</strong></td><td valign="top">No</td></tr><tr><td valign="top"><strong>Uses format-preserving encryption (FPE)</strong></td><td valign="top">No</td></tr><tr><td valign="top"><strong>Privacy ranking</strong></td><td valign="top">5</td></tr><tr><td valign="top"><strong>Generator ID (for the API)</strong></td><td valign="top"><a href="/pages/sIv7iAJxM0EqwLdkBhVc"><code>DateTruncationGenerator</code></a></td></tr></tbody></table>

## How to configure <a href="#date-truncation-configure" id="date-truncation-configure"></a>

To configure the generator:

1. From the dropdown list, select the part of the date or timestamp to truncate to.\
   \
   For both date and timestamp values, you can truncate to the year, month, or day. When you select one of these options, the time portion of a timestamp is set to 00:00:00. For the date, the values below the selected truncation value are set to 01. For example, when you truncate to month, the day value is set to 01, and the timestamp is set to 00:00:00.\
   \
   For a timestamp value, you also can truncate to the hour, minute, or second. The date values remain the same as the original data. The time values below the selected truncation value are set to 00. For example, when you truncate to minute, the seconds value is set to 00.
2. Toggle the **Birth Date** option.\
   \
   When you enable **Birth Date**, the generator shifts dates that are more than 90 years before the generation date to the date exactly 90 years before the generation date.\
   \
   For example, data generation occurs on January 1, 2023. Any date that occurs before January 1, 1933 is changed to January 1, 1933.<br>

   This is mostly intended for birthdate values, to group birthdates for everyone who is older than 89 into a single year. This is used to comply with HIPAA Safe Harbor.
3. From the **Fallback Generator** dropdown list, select how to handle values that the generator cannot process.\
   \
   By default, this is set to **Fail on error**, meaning that the generation fails when a value cannot be processed.\
   \
   You can instead assign a fallback generator, either:
   1. Passthrough, to pass through the value without changing it.
   2. Constant, to use a replacement value that you provide.
   3. Null, to null out the value.&#x20;
4. If [Structural data encryption](/app/generation/generators-assign-config/generators-data-encryption-config.md) is enabled, then to use it for this column, in the advanced options section, toggle **Use data encryption process** to the on position.

## Truncation examples <a href="#date-truncation-examples" id="date-truncation-examples"></a>

Here are examples of date and time values and how the selected truncation affects the output:

<table><thead><tr><th valign="top">Option</th><th valign="top">Date value</th><th valign="top">Timestamp value</th></tr></thead><tbody><tr><td valign="top">Original value</td><td valign="top">2021-12-20</td><td valign="top">2021-12-20 13:42:55</td></tr><tr><td valign="top">Truncate to year</td><td valign="top">2021-01-01</td><td valign="top">2021-01-01 00:00:00</td></tr><tr><td valign="top">Truncate to month</td><td valign="top">2021-12-01</td><td valign="top">2021-12-01 00:00:00</td></tr><tr><td valign="top">Truncate to day</td><td valign="top">2021-12-20</td><td valign="top">2021-12-20 00:00:00</td></tr><tr><td valign="top">Truncate to hour</td><td valign="top">Not applicable</td><td valign="top">2021-12-20 13:00:00</td></tr><tr><td valign="top">Truncate to minute</td><td valign="top">Not applicable</td><td valign="top">2021-12-20 13:42:00</td></tr><tr><td valign="top">Truncate to second</td><td valign="top">Not applicable</td><td valign="top">2021-12-20 13:42:55</td></tr></tbody></table>


---

# Agent Instructions: 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:

```
GET https://docs.tonic.ai/app/generation/generators/generator-reference/date-truncation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
