|
Archives of the TeradataForumMessage Posted: Sat, 13 Apr 2013 @ 16:39:33 GMT
I wish to extract TIME portion from the TIMESTAMP. Some book I read says the following syntax should work : SELECT CAST(CURRENT_TIMESTAMP AS TIME); However this does not work on my system . Hence I created a ungly looking query to extract Time from timestamp. SELECT CAST (CASE WHEN EXTRACT(HOUR FROM CURRENT_TIMESTAMP) > 9 THEN TRIM(EXTRACT(HOUR FROM CURRENT_TIMESTAMP) ) ELSE '0'||TRIM(EXTRACT(HOUR FROM CURRENT_TIMESTAMP) ) END ||':'|| CASE WHEN EXTRACT(MINUTE FROM CURRENT_TIMESTAMP) > 9 THEN TRIM(EXTRACT(MINUTE FROM CURRENT_TIMESTAMP) ) ELSE '0'||TRIM(EXTRACT(MINUTE FROM CURRENT_TIMESTAMP) ) END ||':'|| TRIM(EXTRACT(SECOND FROM CURRENT_TIMESTAMP)) AS TIME ) Does any body have a simpler looking SQL for extracting Time from timestamp? Thanks Sukul Mahadik
| ||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||
Copyright 2016 - All Rights Reserved | ||||||||||||||||||||||||||||||||||||||||||||||||
Last Modified: 15 Jun 2023 | ||||||||||||||||||||||||||||||||||||||||||||||||