|
|
Archives of the TeradataForum
Message Posted: Wed, 21 Apr 2004 @ 11:02:00 GMT
Subj: | | Re: Seconds to time column conversion |
|
From: | | Sanjaya Nagabhushan |
Hope this helps.
Sanjaya
show table a;
*** Text of DDL statement returned.
*** Total elapsed time was 1 second.
---------------------------------------------------------------------------
CREATE SET TABLE TEST.a ,NO FALLBACK ,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT
(
i INTEGER)
PRIMARY INDEX ( i );
BTEQ -- Enter your DBC/SQL request or BTEQ command:
sel*from a;
*** Query completed. One row found. One column returned.
*** Total elapsed time was 1 second.
i
-----------
359999
BTEQ -- Enter your DBC/SQL request or BTEQ command:
.width 220
BTEQ -- Enter your DBC/SQL request or BTEQ command:
sel 'sel cast ((interval '''||trim(i/3600) ||''' hour ) as
interval hour to second(0)) +
cast ((interval '''||trim((i mod 3600)/60)||''' minute) as
interval hour to second(0)) +
cast ((interval '''||trim(i mod 60) ||''' second) as
interval hour to second(0)) as HH_MM_SS;' as Query
from a;
*** Query completed. One row found. One column returned.
*** Total elapsed time was 1 second.
Query
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
----
sel cast ((interval '99' hour ) as interval hour to second(0)) +
cast ((interval '59' minute) as interval hour to second(0)) +
cast ((interval '59' second) as interval hour to second(0)) as HH_MM_SS;
BTEQ -- Enter your DBC/SQL request or BTEQ command:
--Execute the generated query to get the equivalent in HH:MM:SS--
sel cast ((interval '99' hour ) as interval hour to second(0)) +
cast ((interval '59' minute) as interval hour to second(0)) +
cast ((interval '59' second) as interval hour to second(0)) as HH_MM_SS;
*** Query completed. One row found. One column returned.
*** Total elapsed time was 1 second.
HH_MM_SS
-----------
99:59:59
| |