Marcus Monn
Marcus Monn

Reputation: 1

Convert Decimal to Time Output in SQL - Teradata

I am querying via Teradata SQL Assistant and have a field (DECSN_TIME) that outputs as an integar with length between 1 and 6.

I would like to format the integar into a time format (HH:MM:SS)

Example of Output : 1 should be 00:00:01 .... 45 should be 00:00:45 .... 152251 should be 15:22:51 or 03:22:51 PM

Upvotes: 0

Views: 3755

Answers (1)

dnoeth
dnoeth

Reputation: 60472

Format like a TIME, i.e. result is a string:

CAST((DECSN_TIME (FORMAT '99:99:99')) AS CHAR(8))

Actually return a TIME:

CAST(CAST((DECSN_TIME (FORMAT '99:99:99')) AS CHAR(8)) AS TIME(0))

Upvotes: 3

Related Questions