sql - Parse Decimal Second by PostgreSQL -


i parse string

'16:25:20.6598412z'

as timestamp without time zone

the function use is:

to_timestamp('16:25:20.6598412z', 'hh24:mi:ss.msus')

but result is:

16:25:21.5002+01

this have not same time:

16:25:20.6598412

you cannot use ms , us both in 1 to_timezone call - microseconds miliseconds (and little more) how engine know how parse string?

instead should use

    to_timestamp('16:25:20.6598412z', 'hh24:mi:ss.us') 

also notice microseconds due reference value in range of (000000-999999) can pass 6 digits us

    to_timestamp('16:25:20.659841z', 'hh24:mi:ss.us') 

to loose timezone add ::timestamp without time zone; @ end of to_timestamp call

    to_timestamp('16:25:20.6598412z', 'hh24:mi:ss.msus')::timestamp without time zone; 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -