0
votes

I've been trying to figure out a way to have Google calendar dump basically a programmed filtered search result (facilitated by javascript) into a spreadsheet.

I have managed to do both tasks separately such as show only events between these days, and show events between these two times but I haven't found a way to combine the two. Heres what I have to filter the days:

(This will output to each column a calendar and it's events based on the calendar name plugged in and the date range)

function onOpen() {

  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheets()[0];
  cell = sheet.getRange("A1");

  // To change output:  Enter Name of Desired Calendar Below
  cApp = CalendarApp.getCalendarsByName('Calendar Name');      
  for (var b = 0;b < cApp.length;b++){
  cell.offset(0,b).setValue(cApp[b].getName());

  // To change the date range:            Enter the Starting Date Below    
  var events = cApp[b].getEvents(new Date("August 26, 2013 EST"),

  // To change the date range: Enter the Ending Date Below    
  new Date("January 31, 2014 EST"));

  for ( var j=0;j< events.length;j++){
    cell.offset(j+1,b).setValue(events[j].getTitle());
  }
  } 

And this is a minor tweak to allow for a time range:

  function onOpen() {
  var now = new Date('February 28, 2014 00:00:00 PST')
  var then = new Date('February 28, 2014 08:00:00 PST')


  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheets()[0];
  cell = sheet.getRange("A1");

 // To change output:             Enter Name of Desired Calendar Below
  cApp = CalendarApp.getCalendarsByName('Athletics Field');

  for (var b = 0;b < cApp.length;b++){
  cell.offset(0,b).setValue(cApp[b].getName());

  var events = cApp[b].getEvents(now, then);

  for ( var j=0;j< events.length;j++){
    cell.offset(j+1,b).setValue(events[j].getTitle());
  }
  } 
  }

The question more specifically being, I would like to see the events From March 1st to March 8th but ONLY the ones between 12pm and 3pm for example.

Please help? ^^;

1

1 Answers

0
votes

One of the Google Apps Script Templates would be a good place for you to start.

Get an email with the day's agenda: This template will run a daily script to check your appointments on Google Calendar then send you an email with the day's agenda at the time of your choice.

The spreadsheet with script is here.