I have a .shp file with includes a column of format Double that is the Arrival time.

The time values entered are decimal time. For instance, 1 record has a decimal time of 7.11194, which converts to 07:06:43

What is the easiest method to convert this value so I can use it in QGIS?

I've tried using the totime value in QGIS, but no luck.

  • What have you tried so far? I'd simply go for "manual" conversion, aka build a field calculator expression and be done with it. Do you have to repeat this process?
    – Erik
    Jun 15 '20 at 8:46

Wow this is very fun and... extremely hard for me. Assuming "arrival" as your Arrival time field:

Hour........... lpad(to_string(floor("arrival")),2,0)

Minutes...... lpad(to_string((floor("arrival"*60)%60)),2,0)

Seconds..... lpad(to_string(round(("arrival"*3600)%60)),2,0)

Wrapping the above into single expression, it becomes:

lpad(to_string(floor("arrival")),2,0) || ':' || lpad(to_string((floor("arrival"*60)%60)),2,0) || ':' || lpad(to_string(round(("arrival"*3600)%60)),2,0) 

Hope you'll get better answers.

enter image description here

  • Sorry for the delay, this is the first time i've had the chance to try your suggestion, but it has worked I'm not a programmer by any stretch of the imagination; I can do some basic stuff in MapInfo and QGIS, but this had me stumped once trying the totime syntax in qgis failed Thank-you for your assistance regards
    – Simon Hume
    Jun 20 '20 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.