Google-calendar – Calculating total hours of an event in Google Calendar

google-calendar

I'm looking to see or get a weekly summary of the number of hours per event in a Google Calender.

How can I get these hours totalled up?

Best Answer

I wrote up a script in Google Script, which I would like to contribute in case it helps someone else stumbling across this question. I adapted some code from the Google sample code on Calendar API.

The script searches a specific calendar for events within a defined date range and sums up the hours and days that these events have been registered as. It fills the Sheet which is associated to this script with

  • a summary of "Same Name" Events accumulated days and hours
  • a list of each event that was captured with its associated start date, end time and durration in hours.

Steps

1. Go to your google Drive and start a new Empty SpreadSheet.
2. Go to the Menu: Tools --> Script Editor.
3. Copy+paste the code into the new Code.gs and Save the File
4. Go to the Menu: Resources --> Advanced Google Services
5. Scroll till you find the **Calendar API** and turn it **ON** --> Click OK
6. Modify the gbl... vars to suit your interest.
7. Go to the Menu --> Run --> RunMe
8. An Authorization request will popup, (only the first time you run it)
  8a. Click Review Permissions
  8b. Select your google account, click continue
  8c. It will say "This App isn't verified", click Advanced, then Goto <project name> (unsafe)
  8d. It will tell you which permissions are required, Click Allow
9. If all went well you should be able to return to the Sheet and see the results.  
10. For easy Access from the sheet add the function within the Menu: Tools -- > Macros --> Import

---- Functions ----
Run --> RunMe : Runs Using the Defined Range
Run --> RunLast24h : Runs using the last 24h as date range
Run --> RunToday : events from Today
Run --> RunYesterday: events from Yesterday

Here is the link to the script: http://gist.github.com/paucoma/7b7b6cecddfa79d25531#file-gglcaleventsonspreadsheet-gs