Search code examples
timestampteradatateradata-sql-assistant

Integer Conversion into Time(6) in Teradata


I have 2 fields SLA_HR and SLA_MIN in integer ans want to convert into time(6) by concatenating 2 fields SLA_HR and SLA_MIN

Examp Table xyz

SLA_HR SLA_MIN
4        6
12       30

Result :- 04:06:00 12:30:00

It would be great if anyone can help on this.

THANKS


Solution

  • Probably the easiest was is to cast the hours/minutes to intervals:

    TIME '00:00:00' + Cast(SLA_HR AS INTERVAL HOUR) + Cast(SLA_MIN AS INTERVAL MINUTE)
    

    To simplify reusing this calculation you should store it as a SQL UDF.