-Set the maximum times the Dates cte can recurse.LEFT JOIN Events e ON CAST ( CONVERT ( VARCHAR ( 10 ) ,e.EventDate, 101 ) AS DATETIME ) = d.-CTEs defined above are used as the queries for the results.-used in some calculations for display.-used to display day of month on calendar.- date used in all calculations for date.- calculation to determine row record is to display on.- the same date then they will be numbered the same. Used in.-Create some events to place on the calendar.SELECT DATEADD (DAY, 1, ) FROM Dates WHERE Date -Add a record for every day in the range.= DATEADD (DAY, 6- DATEPART (WEEKDAY ) ).= DATEADD (s ,- 1, DATEADD (mm, DATEDIFF (m, 0, GETDATE ( ) ) + 1, 0 ) ).= DATEADD (DAY ,- DATEPART (WEEKDAY ) + 1 ).= DATEADD (s, 0, DATEADD (mm, DATEDIFF (m, 0, GETDATE ( ) ), 0 ) ).Set the maximum times the Dates cte can recurse LEFT JOIN Events e ON CAST(CONVERT(VARCHAR(10),e.EventDate,101) AS DATETIME) = d.
CTEs defined above are used as the queries for the results used to display day of month on calendar calculation to determine row record is to display on. the same date then they will be numbered the same. Number the records based on the date, if multiple records have Create some events to place on the calendar SELECT DATEADD(DAY, 1, ) FROM Dates WHERE Date < Events AS ( SET = DATEADD(s,0,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0)) Copy raw styler DECLARE DATETIME, DATETIME