Reputation: 259
Is there any way convert text to time type? Code in postgresql as below:
to_char(localtimestamp(0),'HH24:mi:SS')
this way I will get the value like 15:15:20
,but this type
is varchar(or text).
How can I do to get the value in time
type?
Thanks!
Upvotes: 6
Views: 18902
Reputation: 425491
SELECT TO_TIMESTAMP('15:15:20', 'HH24:MI:SS')::TIME
Note that your very query (which returns local time) can be rewritten as
SELECT LOCALTIME
which would return TIME
Upvotes: 25