Build a Time Tracker in Google Sheets with Apps Script
A Google Sheet makes a surprisingly good time tracker — especially when backed by Apps Script for clock-in/out buttons, automatic duration calculations, and weekly summaries.
Sheet structure
Create a sheet named Time Log with these columns:
| A: Date | B: Clock In | C: Clock Out | D: Duration (hrs) | E: Notes |
Clock in and clock out
functionclockIn(){const sheet =SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Time Log');const now =newDate();// Check if already clocked in (last row has Clock In but no Clock Out)const lastRow = sheet.getLastRow();if(lastRow >1){const clockOut = sheet.getRange(lastRow,3).getValue();if(!clockOut){SpreadsheetApp.getUi().alert('You are already clocked in. Clock out first.');return;}} sheet.appendRow([now.toDateString(), now,'','','']);SpreadsheetApp.getUi().alert(`Clocked in at ${now.toLocaleTimeString()}`);}functionclockOut(){const sheet =SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Time Log');const lastRow = sheet.getLastRow();if(lastRow <2){SpreadsheetApp.getUi().alert('No active clock-in found.');return;}const clockIn = sheet.getRange(lastRow,2).getValue();const clockOut = sheet.getRange(lastRow,3).getValue();if(clockOut){SpreadsheetApp.getUi().alert('Already clocked out. Use Clock In to start a new session.');return;}const now =newDate();const durationHrs =(now -newDate(clockIn))/(1000*60*60); sheet.getRange(lastRow,3).setValue(now); sheet.getRange(lastRow,4).setValue(parseFloat(durationHrs.toFixed(2)));SpreadsheetApp.getUi().alert(`Clocked out at ${now.toLocaleTimeString()}\nDuration: ${durationHrs.toFixed(2)} hrs`);}
Add a custom menu
functiononOpen(){SpreadsheetApp.getUi().createMenu('⏱ Time Tracker').addItem('Clock In','clockIn').addItem('Clock Out','clockOut').addSeparator().addItem('Weekly Summary','showWeeklySummary').addToUi();}