# Random Timestamp (RandomTimestampGenerator)

The [Random Timestamp](https://docs.tonic.ai/app/generation/generators/generator-reference/random-timestamp) generator generates random dates, times, and timestamps that fall within a specified range.

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

The Random Timestamp generator does not support linking or consistency. You cannot configure differential privacy.

The `metadata` object is populated from the [`TimestampRangeMetadata`](https://app.tonic.ai/apidocs/index.html#/models/TimestampRangeMetadata) object, which includes:

* For text columns, the format of the timestamp in the original data.
* For integer columns, the unit to use for the value. The generator produces a Unix timestamp.
* If the timestamp format includes dates, the minimum and maximum timestamps. Uses the format `yyyy-MM-ddTHH:MM:SSZ`.
* If the timestamp format is time-only, the minimum and maximum timestamps. The date part of the timestamp is ignored. Uses the format y`yyy-MM-ddTHH:MM:SSZ`.

```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": "RandomTimestampGenerator",
    "dateTimeFormat": "enum",  //For text columns
    "unixTimestampFormat": "enum"  // For integer columns
    "minDate": "timestamp",  //For formats with dates
    "maxDate": "timestamp",  //For formats with dates
    "minTime": "timestamp"   //For time-only formats
    "maxTime": "timestamp"   //For time-only formats,
    "encryptionProcessor": "x-on", //To use configured Structural data encryption
    "customValueProcessor": "string"  //If custom value processor is applied
  }
}
```

## Example replacements <a href="#generator-api-random-timestamp-replacement" id="generator-api-random-timestamp-replacement"></a>

In the following example replacement for the Random Timestamp generator, the source column is a text column.

The format for the timestamps in the original data is `yyyy-MM-dd HH:mm:ss`.

The timestamps occur between November 20, 2022 at 8:57:14 PM and November 21, 2022 at 8:57:14 PM.

```json
{
  "name": "start",
  "schema": "public",
  "table": "users",
  "links": [
    {
      "column": "start",
      "table": "users",
      "schema": "public",
      "metadata": {
        "presetId": "RandomTimestampGenerator",
        "generatorId": "RandomTimestampGenerator",
        "dateTimeFormat": "yyyy-MM-dd HH:mm:ss",
        "minDate": "2022-11-20T20:57:14Z",
        "maxDate": "2022-11-21T20:57:14Z"
      }
    }
  ]
}
```

The following example uses the same range as the previous example, but the column is an integer column. The generator is configured to produce Unix timestamps in seconds.

```json
{
  "name": "start",
  "schema": "public",
  "table": "users",
  "links": [
    {
      "column": "start",
      "table": "users",
      "schema": "public",
      "metadata": {
        "presetId": "RandomTimestampGenerator",
        "generatorId": "RandomTimestampGenerator",
        "unixTimestampFormat": "Seconds",
        "minDate": "2022-11-20T20:57:14Z",
        "maxDate": "2022-11-21T20:57:14Z"
      }
    }
  ]
}
```

The following example generates time-only values between 8:00 AM and 5:00 PM. The date part of the `minTime` and `maxTime` values is ignored.

```json
{
  "name": "start",
  "schema": "public",
  "table": "users",
  "links": [
    {
      "column": "start",
      "table": "users",
      "schema": "public",
      "metadata": {
        "presetId": "RandomTimestampGenerator",
        "generatorId": "RandomTimestampGenerator",
        "dateTimeFormat": "HH:mm:ss",
        "minTime": "2022-11-20T08:00:00Z",
        "maxTime": "2022-11-20T17:00:00Z"
      }
    }
  ]
}
```


---

# 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/api/quick-start-guide/tonic-api-generator-assignment/generator-api-reference/generator-api-ref-random-timestamp.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.
