Generating a n date range

The following code demonstrates how to generate a date range for some $n$ range value. To use this approach, use any dummy table you may have on your database. Make sure the table has the right length for the date range.

In this example, we generate a date range of the first eight days of march. Starting from '2025-03-01'

SELECT 
    date('2025-03-01') + a.n * interval '1 day' as date_range 
FROM (
  SELECT 
      ROW_NUMBER() OVER() - 1 AS n 
  FROM 
    enrollments 
  LIMIT 8
  ) a;
  
date_range --------------------- 2025-03-01 00:00:00 2025-03-02 00:00:00 2025-03-03 00:00:00 2025-03-04 00:00:00 2025-03-05 00:00:00 2025-03-06 00:00:00 2025-03-07 00:00:00 2025-03-08 00:00:00 (8 rows)