DATE_ADD and DATE_DIFF Basics
Concepts covered: sqlDateAdd
INTERVAL is the SQL primitive for adding or subtracting time spans. CURRENT_DATE + INTERVAL '7 days' returns next week. signup_date + INTERVAL '90 days' returns the date 90 days after signup. The result is a date or timestamp (depending on the input); the arithmetic respects calendar rules (month and year intervals handle variable-length months correctly). INTERVAL is the workhorse for relative date windows. The canonical windowing patterns INTERVAL units and how engines parse them Most engines accept the same set of unit strings: 'seconds,' 'minutes,' 'hours,' 'days,' 'weeks,' 'months,' 'years.' The number can be any integer, positive or negative. INTERVAL '1 day,' INTERVAL '30 days,' INTERVAL '-7 days' are all valid. Engines vary in how they parse the literal: Postgres accepts 'X days' a
About This Interactive Section
This section is part of the Date Arithmetic: Beginner lesson on DataDriven, a free data engineering interview prep platform. Each section includes explanations, worked examples, and hands-on code challenges that execute in real time. SQL queries run against a live database. Python runs in a sandboxed Docker container. Data modeling problems validate against interactive schema canvases. All content is framed around what data engineering interviewers actually test at companies like Meta, Google, Amazon, Netflix, Stripe, and Databricks.
How DataDriven Lessons Work
DataDriven combines four interview rounds (SQL, Python, Data Modeling, Pipeline Architecture) with adaptive difficulty and spaced repetition. Easy problems get harder as you improve. Weak concepts resurface until you master them. Your readiness score tracks progress across every topic interviewers test. Every lesson section ends with problems you solve by writing and running real code, not by picking multiple-choice answers.