Text and date commands in Spreadsheet

andesan shared this question 6 years ago
Answered

How can I convert a timestamp like "06:55:07.852" to seconds?


I typical have cells in a spreadsheet with such timestamps, and I want to calculate the time difference between two cells (in seconds).


One idea is to split the timestamp string into hours, minutes and seconds using some kind of substring command. But I can not find a GeoGebra command to extract substrings from a cell.

Comments (3)

photo
1

Try:

    text1 = Take["06:55:07.852", 1, 2]

    text2 = Take["06:55:07.852", 4, 5]

    text3 = Take["06:55:07.852", 7, 8]

    text4 = Take["06:55:07.852", 10, 12]

    ParseToNumber[a, text1]

photo
1

Thank you, Mike!

This works fine, except that I need to use the command 'FromBase' instead of 'ParseToNumber'. The formula in my spreadsheet now looks like 'FromBase[Take[$F2, 1, 2], 10]'.

photo
1

Yes, even better :)

© 2022 International GeoGebra Institute