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

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s