Monthly Archives: January 2017

Converting long value in string to timestamp

\d student
Column        |         Type                        | Modifiers
—————-+———————–+———–
id                      | numeric(20,0)             |
name               | character varying(50) |
joiningtime    | character varying(30) |

select id,name,joiningtime,to_timestamp(CAST(coalesce(joiningtime, ‘0’) AS numeric)/1000) from student

id        | name      |  joiningtime     |         to_timestamp
——–+———-+—————+——————————-
168364 | Ravi        | 1484833632817 | 2017-01-19 19:17:12.817+05:30
168351  | Kumar   | 1484833632296 | 2017-01-19 19:17:12.296+05:30