---
schema_version: "1"
id: dedfa75abcd50f8b9ee7560dc1e76157e70902f54f0ca888fef0e2cfa4a5e2c2
title: TO_TIMESTAMP
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/data-cloud-query-guide/references/data-cloud-sql-reference/scalar-func/formatting-func/to-timestamp.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/to-timestamp.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 20ebf882f3bf540b50154335b7aecd8605071182585e88c114a7eb38d8285fa6
products:
  - Data 360 Query Guide
  - Data 360 Developer Documentation
---
# `TO_TIMESTAMP`

**Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

Converts a formatted string to a `timestamp with time zone` value according to the supplied format pattern.

## Syntax

```sql
to_timestamp(<string>, <format_pattern>)
```

## Arguments

### Required

-   `<string>`: A `text` value representing the timestamp to parse.
-   `<format_pattern>`: A `text` value specifying the format of the input string. Template pattern characters in the format string identify the corresponding parts of the input value.

## Returns

Returns `timestamp with time zone`.

Returns NULL if either argument is NULL.

## Considerations

-   For supported format pattern characters and modifiers, see [TO_CHAR](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/to-char.md).
-   Use `TO_TIMESTAMP` when a simple cast can't handle your input format. For most standard date/time formats, cast the source string directly to `timestamp` without `TO_TIMESTAMP`.
-   The `YYYY` pattern can't process a year with more than four digits. Use a non-digit separator after `YYYY` for longer year values. For example, `to_timestamp('20000-11-30', 'YYYY-MM-DD')`.
-   Millisecond (`MS`) and microsecond (`US`) fields are treated as the fractional seconds digits after the decimal point. For example, `to_timestamp('12.3', 'SS.MS')` produces 12.300 seconds (300 milliseconds), not 12.003.
-   ISO 8601 week-numbering fields (`IYYY`, `IW`, `ID`, `IDDD`) can't be mixed with Gregorian date fields in the same call.

## Examples

### Parse a Date String into a Timestamp

Convert a human-readable date string to a `timestamp with time zone`.

```sql
SELECT to_timestamp('05 Dec 2000', 'DD Mon YYYY');
```

Returns `2000-12-05 00:00:00+00`.

### Parse a Full Datetime String with Time Zone Offset

Convert a string that includes time and time zone offset components.

```sql
SELECT to_timestamp('2024-03-15 14:30:00 -07', 'YYYY-MM-DD HH24:MI:SS TZH');
```

Returns `2024-03-15 14:30:00-07`.

## Related Documentation

-   [TO_CHAR](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/to-char.md)
-   [TO_DATE](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/to-date.md)
-   [Formatting Functions](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/formatting-func.md)
