Forum Discussion
Convert HH:MM:SS to seconds
- 6 years ago
Hi IPGeorgiev,
To avoid having to split the column by delimeter in the case you aren't sure of the length of each string being consistent always you can apply the same methods but using a combination of Text.BeforeDelimeter, Text.AfterDelimeter and Text.BetweenDelimeter M functions.
Number.FromText( Text.BeforeDelimiter( [Time], ":" ) ) * 3600 + Number.FromText( Text.BetweenDelimiters( [Time], ":", ":", 0, 0 ) ) * 60 + Number.FromText( Text.AfterDelimiter( [Time], ":", 1 ) )Hope it helps.
Kris
Hi IPGeorgiev ,
There are some existing threads for this query:
https://community.powerbi.com/t5/Desktop/Converting-HH-MM-SS-to-seconds/m-p/674207
https://community.powerbi.com/t5/Desktop/How-to-convert-HH-MM-SS-to-seconds-using-DAX/m-p/857997
Thanks,
Pragati
Hi Pragati11 ,
when trying TIMEVALUE in Query Editor the function is not being recognized. Then if I try to add a new column in POwerBI Desktop it returns an error.
Here when I try with:
= Table.AddColumn(#"Changed Type4", "Custom", each [Talk Time]*86400)
Expression.Error: We cannot apply operator * to types Time and Number.
Details:
Operator=*
Left=12:03:17 AM
Right=86400
If I leave it just as text and not as time:
Expression.Error: We cannot apply operator * to types Text and Number.
Details:
Operator=*
Left=0:03:17
Right=86400
When I try this:
Column = MINUTE(Table[date time])*60+SECOND(Table[date time])
I get:
Cannot convert value '26:11:52' of type Text to type Number.
So no success with those two option as I have tried them prior to opening the thread.