# Date Truncation (DateTruncationGenerator)

The [Date Truncation](https://docs.tonic.ai/app/generation/generators/generator-reference/date-truncation) generator 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.

## Link object structure <a href="#generator-api-date-truncation-link-object" id="generator-api-date-truncation-link-object"></a>

The Date Truncation generator does not support linking or consistency. You cannot configure differential privacy.

The `metadata` object is populated from the [`DateTruncationMetadata`](https://app.tonic.ai/apidocs/index.html#/models/DateTruncationMetadata) object. The generator-specific configuration includes the part of the datetime value to truncate to, and whether to change all dates that are more than 90 years before the generation date to a date exactly 90 years before the generation date.

```json
{
  "schema": "string",
  "table": "string",
  "column": "string",
  "path": "string",  //JSON fields only
  "dataType": "string",  //MongoDB, Amazon DynamoDB, and JSON fields only
  "metadata": {
    "presetId": "string",
    "generatorId": "DateTruncationGenerator",
    "datePart": "enum",
    "isBirthDate": boolean,
    "encryptionProcessor": "x-on", //To use configured Structural data encryption
    "customValueProcessor": "string"  //If custom value processor applied.
  }
}
```

## Example replacement <a href="#generator-api-date-truncation-replacement" id="generator-api-date-truncation-replacement"></a>

In the following example replacement for the Date Truncation generator, the values are truncated to the year. Date values that are older than 90 years before the generation date are not changed.

```json
{
  "name": "event_date",
  "schema": "public",
  "table": "events",
  "links": [
    {
      "schema": "public",
      "table": "events",
      "column": "event_date",
      "metadata": {
        "presetId": "DateTruncationGenerator",
        "generatorId": "DateTruncationGenerator",
        "datePart": "Year",
        "isBirthDate": false
      }
    }
  ]
}
```
