Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Convert number to Hours & Minutes

Sahil7
5 - Atom

I am trying to convert numbers to hours, i have looked at all solutions in community but nothing seems to be working. I have used ToDateTime([Time])/1440

 but its giving me error as Error: Type mismatch in operator +.

 

I have made sure to use Select tool and clean the datatype as Double.

 

Can someone pls help with simple solution, incase of bigger formula pls help with explanation.

 

Thanks you

6 REPLIES 6
SPetrie
13 - Pulsar

Can you give an example input and expected output of what you are trying to do?

Your title says numbers to hours/minutes but the formula and Double type seems to indicate you want a number.

Sahil7
5 - Atom

Sure, so i have a column that has hours in numbers, for ex: 7.5. I want to convert 7.5 to 07:30 hrs.

SPetrie
13 - Pulsar

You can use this formula

datetimeformat(DateTimeAdd("1901-01-01 00:00:00", 60*[Time],"minutes"),"%H:%M")

 

Multiply the 7.5 (Time column) by 60 to get the number of minutes

Add those minutes to a generic date time of midnight and then format to be just the hour and minute.

 

Time.PNG

Sahil7
5 - Atom

Thanks for this, but there are certain cells that has number with 6 decimals. for ex 7.139456. its not working on those cell, any refining?

Diemm
8 - Asteroid

You can use the formula that the previous guy give you, but add a formula before to limite the number of decimals (like round) to make the datetime formula works.

SPetrie
13 - Pulsar

In what way is it not working? Can you share a screenshot or the error message?

Are they coded as numbers or a string?

When I try 7.139456 in the formula I get 7:08 as the result.

 

Labels
Top Solution Authors