Back to articles list Articles Cookbook
11 minutes read

SQL Meets Google Calendar: Analyze a Year in Meetings

Do you ever feel like your calendar is running your life? Back-to-back meetings, barely any time to get actual work done – and no idea where your time went? You're not alone.

What if you could run a quick SQL query and know exactly how much time you spent in meetings last year, which months were the busiest, and whether your weekly syncs are eating up your mornings?

That’s what this guide is all about. I'll show you how to export your Google Calendar, transform it into a SQL-friendly format, and use plain SQL queries to analyze your meeting habits over the past year.

Want to brush up on your SQL before diving in? Check out SQL Basics course. It’s perfect for beginners or anyone wanting to level up their query game.

Why Analyze Your Calendar?

Why even bother analyzing your calendar? Here are a few real reasons:

  • You want to see how much time you're spending in meetings. It’s easy to lose track when every day has two or three blocks booked. Seeing the total number of hours can be eye-opening.
  • You suspect some days or weeks are overloaded. Maybe Wednesdays are always packed, or every Monday feels like a marathon of calls. You want to find those patterns with real data.
  • You’re curious if recurring meetings are actually useful. Weekly syncs and biweekly check-ins often become routine. Analyzing them can help you figure out if they’re helping or just filling up your calendar.
  • You want data-driven reasons to say “no” to another invite. Having numbers to back your decision can help you make the case for fewer meetings and more focused time.

This kind of insight can help you reclaim your time, make smarter scheduling decisions, and reduce meeting fatigue.

Now, let’s get that data.

Step 1: Export Your Google Calendar

Google Calendar doesn’t give you an Excel sheet with all your meetings, but you can export your data in .ics format.

How to Export:

  1. Go to Google Calendar.
  2. Click the ⚙️ gear icon → Settings.
  3. Scroll to Import & Export.
  4. Under “Export,” click Export. You’ll get a ZIP file.
  5. Unzip it to find .ics files for each calendar.

Make sure you include all relevant calendars (work, personal, shared, etc.).

Step 2: Convert the .ics File to a SQL-Compatible Format

Before we do anything else, we need to turn that .ics file into something more useful – like a .csv file, which works just like a spreadsheet and is easy to import into any SQL database.

To do this, we’ll use a simple Python script. If you’ve never used Python before, don’t worry – this is a step-by-step approach. The script will read the .ics file, pull out each event (like a meeting or appointment), and save those details into a .csv file.

Here’s what you need to get started:

  • Python installed on your computer (version 3.x is fine).
  • Two Python libraries:
    • icalendar: helps Python understand calendar files.
    • pandas: helps manage and save data in table format.

You can install these libraries by opening your terminal or command prompt and running:

pip install icalendar pandas

Python Script Explained

Don't feel overwhelmed by the length of the script below – it may look complex, but you don’t need to write any of it yourself. You’ll just copy and paste it into a file and run it. Everything is already set up to do the work for you.

from icalendar import Calendar
import pandas as pd

# Read the .ics calendar file
with open("calendar.ics", encoding="utf-8") as f:
    cal = Calendar.from_ical(f.read())

# Create a list to store extracted events
events = []

# Walk through each event in the calendar
for component in cal.walk():
    if component.name == "VEVENT":
        event = {
            'summary': str(component.get('summary')),
            'start': component.get('dtstart').dt,
            'end': component.get('dtend').dt,
            'organizer': str(component.get('organizer')),
            'attendees': str(component.get('attendee')),
        }
        events.append(event)

# Convert list to DataFrame and export to CSV
df = pd.DataFrame(events)
df.to_csv('calendar_events.csv', index=False)

This script reads your calendar, loops through each event, and pulls out fields like the name of the meeting, start and end times, who organized it, and who attended. Then it saves everything in a CSV file, ready to import into SQL.

What to do With This Code:

  1. Copy the entire script into a new Python file. You can do this in any text editor – just save it with a .py extension, for example convert_calendar.py.
  2. Make sure your .ics file is in the same folder as your script and is named calendar.ics. If it has a different name, update the file name in the open() function.
  3. To run the script, open your terminal (on Mac or Linux) or Command Prompt (on Windows). Navigate to the folder where you saved the Python file. Then type python convert_calendar.py and press Enter. This tells your computer to execute the script. If everything is set up correctly, it will process the .ics file and create a new file called calendar_events.csv in the same folder. That CSV file will contain all your Google Calendar events in a format that's easy to use in SQL.
  4. After the script runs, you should see a new file called calendar_events.csv in the same folder. That file will contain all your calendar events in a simple table format, ready for use in SQL.

Here’s what your CSV might look like:

summarystartendorganizer
Weekly Sync2024-01-04 10:002024-01-04 10:30alice@company.com
1:1 with Tom2024-01-05 14:002024-01-05 14:45tom@company.com

Step 3: Import the CSV Into Your SQL Database

You can use any SQL database – MySQL, PostgreSQL, or SQLite. In this section, we’ll show you how to do it using PostgreSQL, which is widely used in business environments and perfect for learning real-world SQL skills.

If you’re using Windows and don’t have PostgreSQL installed yet, don’t worry – it’s easy to get started. Just go to the official PostgreSQL website and download the installer. Run the installer, follow the steps, and choose the default settings unless you have a reason to change them.

Make sure you install pgAdmin as well – it’s a visual tool that helps you manage your PostgreSQL database without using the command line. Once installed, you’ll be able to open pgAdmin, connect to your local server, and create your first database with just a few clicks.

Step 1: Set Up Your PostgreSQL Table

Open your terminal or pgAdmin and connect to your PostgreSQL database. Then create a table to hold your meeting data:

CREATE TABLE meetings (
    id SERIAL PRIMARY KEY,
    summary TEXT,
    start TIMESTAMP,
    "end" TIMESTAMP,
    organizer TEXT,
    attendees TEXT
);

This will create a table where each meeting is stored as a row. The SERIAL keyword creates an auto-incrementing ID, and TIMESTAMP stores the date and time for start and end.

Step 2: Load the Data From the CSV File

Now that your table is ready, you need to import the CSV file you created earlier (calendar_events.csv). PostgreSQL uses the COPY command to load CSV data into a table.

If you're using pgAdmin, you can also do this via the GUI:

  • Right-click on the meetings table in the left-hand panel under your database.
  • Choose Import/Export from the context menu.
  • In the dialog window, select Import as the option.
  • Choose your calendar_events.csv file from your computer.
  • Under the Format dropdown, select csv.
  • Make sure the column order in your CSV file matches the table structure.
  • Leave other settings as default, or adjust the delimiter if needed.
  • Click OK to import.

Alternatively, if you prefer using a SQL command in pgAdmin's Query Tool, you can do it like this:

COPY meetings(summary, start, "end", organizer)
FROM 'C:/full/path/to/calendar_events.csv'
DELIMITER ','
CSV HEADER;

Make sure to replace C:/full/path/to/calendar_events.csv with the actual path to your CSV file. Also, be sure PostgreSQL has permission to access that folder. This method can be faster if you're comfortable typing a bit of SQL.

Once you complete this step, your calendar data will be available in PostgreSQL.

Step 4: Analyze Your Meetings With SQL

Now for the fun part. Let’s run some SQL queries to explore your meeting patterns and answer common questions like: How many meetings did I attend? Which days were the busiest? How much time did I spend in meetings?

Total Number of Meetings

SELECT COUNT(*) AS total_meetings FROM meetings;

This query simply counts how many rows exist in the meetings table. Since each row represents one meeting, the result shows how many meetings you've had in total.

Total Time in Meetings (Hours)

SELECT 
  ROUND(SUM(EXTRACT(EPOCH FROM ("end" - start)) / 3600.0)::numeric, 2) AS total_hours
FROM meetings;

This query calculates the total time you spent in meetings by subtracting the meeting start time from the end time. In PostgreSQL, the subtraction of two timestamps returns the duration in seconds, so we use EXTRACT(EPOCH FROM (...)) to get the number of seconds. Then we divide by 3600 to convert it into hours. Finally, ROUND(..., 2) is used to make the result easier to read by limiting it to two decimal places.

Average Meeting Length (Minutes)

SELECT 
  ROUND(AVG(EXTRACT(EPOCH FROM ("end" - start)) / 60.0)::numeric, 1) AS avg_minutes
FROM meetings;

This query calculates the average duration of all your meetings. It subtracts the start time from the end time for each meeting to get the duration, then uses EXTRACT(EPOCH FROM ...) to convert that time into seconds. Dividing by 60 changes seconds into minutes. Finally, AVG gives you the average meeting length, and ROUND(..., 1) makes it easier to read by keeping just one decimal place.

Meetings by Month

SELECT 
  TO_CHAR(start, 'YYYY-MM') AS month,
  COUNT(*) AS meeting_count
FROM meetings
GROUP BY month
ORDER BY month;

This query helps you understand how your meetings were spread across each month. It uses TO_CHAR(start, 'YYYY-MM') to turn each meeting's date into a simplified year-month format like 2024-03, which makes it easier to group events by month. The COUNT(*) function counts how many meetings happened in each of those months. Finally, ORDER BY month organizes the results in chronological order so you can see your busiest months at a glance.

Top 5 Busiest Days

SELECT 
  date(start) AS day,
  COUNT(*) AS meetings
FROM meetings
GROUP BY day
ORDER BY meetings DESC
LIMIT 5;

This shows the five days when you had the most meetings. date(start) extracts just the day from the full timestamp. GROUP BY groups events by day, and ORDER BY meetings DESC puts the busiest days at the top. LIMIT 5 shows only the top five.

Step 5: Visualize the Data

You can use:

  • Power BI or Tableau for dashboards.
  • Google Sheets for quick charts.
  • Python (Matplotlib/Seaborn) for heatmaps.

Try creating a weekly heatmap to spot overloaded days. Pivot your data by weekday and hour, then apply conditional formatting.

Use Cases for Different Roles

Managers can use this analysis to understand how their team's time is actually being spent. If meetings take up more time than expected, they can start identifying which ones are essential and which ones can be trimmed or removed entirely.

Developers often struggle to find large blocks of time for focused coding. By running these queries, they can spot patterns in meeting overload and advocate for fewer interruptions during deep work hours.

Marketers can review how much of their time is spent in planning sessions versus execution work. This can lead to better scheduling of campaign work and more efficient meetings that are focused and goal-driven.

Teachers and educators can benefit by examining how their time is divided between recurring class sessions, one-on-one meetings with students, and administrative tasks. With this insight, they can look for better balance and potentially reduce burnout.

Optional: Automate the Whole Thing

Want to do this regularly? Think about one of those options:

Google Calendar API – This is an official tool provided by Google that lets you programmatically access your calendar data in real-time. You can write a Python script that connects to the API and fetches your events every week or month. This way, you don’t need to export .ics files manually.

Automate with Python – Once you’ve set up the script to fetch and process the calendar data, you can schedule it to run automatically (e.g., every month) using tools like Windows Task Scheduler or cron on Mac/Linux. This saves time and keeps your data fresh.

Zapier – This is a no-code tool that connects different apps together. You can use Zapier to automatically copy events from Google Calendar into a Google Sheet. From there, you can import that sheet into your SQL database. This option is great if you’re not ready to write Python code.

This section is meant to help you scale your process so it runs on its own, with little effort after setup.

Next Steps

Want to build more powerful queries? Learn SQL step-by-step with SQL Basics on LearnSQL.com.

In this hands-on course, you’ll learn how to write real SQL queries that pull meaningful data from a database. You'll cover core topics like selecting columns, filtering rows, sorting results, and joining multiple tables – everything you need to start analyzing data like a pro.

SQL Meets Google Calendar

The course is structured into bite-sized lessons, each with interactive exercises to help you practice as you learn. You don’t need any prior experience: everything is explained clearly and gradually.

By the end, you’ll be comfortable using SQL to answer questions, solve problems, and uncover insights from any data source. It’s the perfect foundation for anyone working with data. And the best part? You can try it out with a free trial to see how it works before committing.

Use your data. Improve your schedule. Save your time!