Search code examples
sqlpostgresqldatedata-conversiondate-arithmetic

Convert hh:mm:ss.ms to millisecond in postgres


I have doubt. how to convert hh:mm:ss.ms to millisecond in Postgres.

For example 01:25:43.81 to 5143810


Solution

  • You could do:

    extract(epoch from '01:25:43.81'::time) * 1000
    

    The other way around:

    '00:00:00'::time + 5143810/1000.0 * interval '1' second