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:
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.
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER