Page 1 of 1

time only from timestamp

Posted: Mon Feb 02, 2015 9:04 pm
by evaleah
How do I extract just the time from a timestamp to end up with a value that would go into a time column? I tried

Code: Select all

select TRUNC(TIMESTAMP '2012-02-12 12:00:00', 'HH:MI:SS');
But I got the following error

Code: Select all

[Vertica][VJDBC](5026) ERROR: Timestamp units "HH:MI:SS" not recognized [SQL State=22023, DB Errorcode=5026]
I want to return just the value '12:00:00'.

Thanks!

Re: time only from timestamp

Posted: Mon Feb 02, 2015 9:12 pm
by JimKnicely
Try the TO_CHAR function:

Code: Select all

dbadmin=> select TO_CHAR(TIMESTAMP '2012-02-12 12:00:00', 'HH:MI:SS');
 TO_CHAR
----------
 12:00:00
(1 row)

Re: time only from timestamp

Posted: Fri Feb 06, 2015 7:49 pm
by evaleah
Thanks!