|
|
Archives of the TeradataForum
Message Posted: Fri, 21 Mar 2003 @ 17:21:50 GMT
Subj: | | Re: Error Trapping with Timestamp |
|
From: | | Maxwell, Donald |
Try:
SELECT '2003-03-31 24:00:00' MyCol
,CAST(substring(MyCol, 1, 10) || ' 00:00:00' AS TIMESTAMP(0)) A
,CAST(substring(MyCol, 12, 8) AS INTERVAL HOUR TO SECOND) B
,A + B CorrectTimestamp
This will yield a CorrectTimestamp of '2003-04-01 00:00:00'
The key is to treat the date and time portions of your string as seperate datatypes, timestamp and interval respectively. Then you can
just add the interval to the timestamp to get the correct timestamp.
Donald Maxwell
| |