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,
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
- jdbuchanan716 years ago
Super User
Nice kriscoupe I was not aware of the Text.*Delimiter funtions in PQ. IPGeorgiev you should go with this solution from kriscoupe
- IPGeorgiev6 years ago
Helper III
Awesome!!! Many many thanks for the support!