time only from timestamp

Moderator: NorbertKrupa

Post Reply
evaleah
Newbie
Newbie
Posts: 3
Joined: Fri Jan 30, 2015 8:03 pm

time only from timestamp

Post by evaleah » Mon Feb 02, 2015 9:04 pm

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!

User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1825
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Re: time only from timestamp

Post by JimKnicely » Mon Feb 02, 2015 9:12 pm

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)
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

evaleah
Newbie
Newbie
Posts: 3
Joined: Fri Jan 30, 2015 8:03 pm

Re: time only from timestamp

Post by evaleah » Fri Feb 06, 2015 7:49 pm

Thanks!

Post Reply

Return to “New to Vertica SQL”