I admit, this is a brute force method but I have used it in the past.
Given these 4 variables, I can calculate the StartCalendarId with padded 0's
Declare @StartDate date
Declare @StartYear int
Declare @StartMonth int
Declare @StartDay int
Set @StartYear = Year(@StartDate)
Set @StartMonth = Month(@StartDate)
Set @StartDay = Day(@StartDate)
Set @StartCalendarId =
(CONVERT([int],
(((CONVERT([varchar](4),@StartYear)+
case when len(@StartMonth)=(1) then '0' else '' end)+
CONVERT([varchar](2),@StartMonth))+
case when len(@StartDay)=(1) then '0' else '' end)
+CONVERT([varchar](2),@StartDay))
)