Convert times to decimal | Google scripts | Spreadsheets | Toggl
Published by Nicholas Dunbar on December 24th, 2012
If in a Google Docs spreadsheet you want to convert a row of values like
"1:36:54"
which represents (hours:minutes:seconds) to something like this
"1.615"
then you are in the right place.
This is a script that will allow you to batch proccess times imported from a program like Toggl (toggl.com) to a decimal form of hours from a string like hours:minutes:seconds. Just create a script in your spreadsheet by clicking tools "script manager" - > "new…"
Then cut and past the following code in, save and then play with it on some test data before applying it to your actual spreadsheet.
I wrote this because I wanted to use toggl to export a CSV file and then import it into a Google Doc Spreadsheet. This was easy enough but I wanted to charge my hourly rate on the time spent since it was in this time format (hours:minutes:seconds) I could not multiply my hourly rate times this number so I had to build a script to convert all the time codes to decimal representations in hours. This is a good work around if you don't want to pay toggle for the extended account that allows you to create invoices and such. I hope it helps you out.