Link to home
Start Free TrialLog in
Avatar of Ryan Simmons
Ryan Simmons

asked on

Create a Calendar Table with Quarter Hour Granularity

Create a calendar table down to Week, Day, and 15 Minute Intervals

My week starts on a Sat and ends on a Fri

This code can create a calendar table with the Day, IsoWeek No., and Week No:
     SELECT  DATEADD(DAY, ROW_NUMBER() OVER ( ORDER BY A.object_id) - 1, '20000101') AS DayDate,
                YEAR(DATEADD(DAY, ROW_NUMBER() OVER ( ORDER BY A.object_id) - 1, '20000101')) AS YearNo,
                DATEPART(ISO_WEEK, DATEADD(DAY, ROW_NUMBER() OVER ( ORDER BY A.object_id) - 1, '20000101')) AS IsoWeekNo,
                DATEPART(WEEK, DATEADD(DAY, ROW_NUMBER() OVER ( ORDER BY A.object_id) - 1, '20000101')) AS WeekNo
        FROM    sys.objects A, sys.objects

Open in new window


Is there a way to take this calendar table down to the Quarter Hour?

So the end result may look like this:

DayDate
01/01/2000 00:00:00
01/01/2000 00:15:00
01/01/2000 00:30:00
01/01/2000 00:45:00
01/01/2000 01:00:00
01/01/2000 01:15:00
and so on until we get to the end of the day and until the completion of the calendar table.
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ryan Simmons
Ryan Simmons

ASKER

Thank you!