Skip to content
Advertisement

EXTRACT the date and time – (Teradata)

I am trying to extract the date and time from a field in Teradata.

The field in question is:

Here is what the data look like:

I’d like the date and time only.

I have tried using EXTRACT(Date, EXTRACT(DAY_HOUR and a few others with no success.

DATE_FORMAT() does not appear to work since I’m on Teradata.

How would I select the date and time from VwNIMEventFct.EVENT_GMT_TIMESTAMP?

Advertisement

Answer

If the datatype of EVENT_GMT_TIMESTAMP is a TIMESTAMP, it’s simple Standard SQL:

If it’s a CHAR you need to apply a FORMAT, too:

Edit:

For simply changing the display format you need to add a FORMAT and a CAST to a string:

If you don’t care about display, just want to truncate the seconds:

Working with timestamps is a bit tricky 🙂

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement