I have a shapefile line layer with an attribute for time in float format.
This is what 23.21 and 55 seconds looks like:
This is 03.27 and 01 seconds:
I would like to convert this to a proper time format in Field Calculator.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
This should do the trick:
to_time( to_string( "<float_time_field>" ), 'hmmss.z' )
Since Shapefiles do not support
time data types (there is
date, but that cannot work without a date...), an easy fix for the above would be to write a string representation of your time:
format_date( to_time( to_string( "<float_time_field>" ), 'hmmss.z' ), 'hh:mm:ss:z' )
:z to not include milliseconds.
While you could achieve the same results with plain regexp logic, using the
time detour is somewhat more convenient.