Timestamp to Date conversion in Teradata

Data types in Teradata

Timestamp and Date are different data types in Teradata. Each of them used for specific purpose in a Table.

  • Timestamp – Date + Time details are stored in a single field
  • Date – only Date value( YYYY/MM/DD) entered in a field.

Lets look at the Timestamp to Date conversion with an example.

Data type conversion in Teradata

CAST() function is used to perform the run time conversion between the compatible data types. We can use this function to convert the Timestamp to Date value.

Example : Timestamp to Date conversion in Teradata

Here is the customer_transaction table which contains the timestamp value for cre_ts column.

Timestamp value in Teradata
Timestamp value in Teradata

As we mentioned the CAST(cre_ts as DATE) in the select query, the cre_ts column is converted from Timestamp to Date value as below.

Timestamp to Date conversion in Teradata
Timestamp to Date conversion in Teradata

Recommended Articles

Timestamp data type in Teradata with examples