
I created a fact table with some dates and a calendar table, manage the 1-1 relationship between them. please follow below steps to generate the results:
0means before 3rd date there is no any sundayof first week -0means before 3rd date there is no any saturday of first week)įurthermore, please confirm how do you define the week? If there’s a Sunday appeared before that day (or Sunday = that day), we can count there’s 1 week before? For example, in June 2, there’s 1 week before June 2nd, or there’s 0 week?Īssuming that the first logic is right, and if the week has Sunday, then we call there’s 1 week counted. (if end date is sunday then 1 else 0) - (ifd end date of the month is saturday then 1 else 0)). ( 0means before 3rd date there is no any sundayof first week - 0means before 3rd date there is no any saturday of first week).
(if first day of the month is sunday then 1 else 0) - (if date is saturday then 1 else 0)). Note : multifly need *2 doesn't confused in your sentences, for the same number, you defined them in different calculation. (3-(0 Weeks *2) - 0 - 0) * (28 - (4*2) - 0-0) = 60ģmeans enddate -( 0 weeks means before 3rd date there is no this month weeks *2)-( 0 means before 3rd date there is no any sundayof first week - 0means before 3rd date there is no any saturday of first week) * ( 28means july month of dates 31-3=28 -( 4*2 means 28th date of how many weeks there is july month -0 means before 3rd date there is no any sundayof first week -0means before 3rd date there is no any saturday of first week)= 60 ((remaing days in the month from the date supplied) - ((no of weeks from date supplied and last day of the month)*2) - (if end date is sunday then 1 else 0) - (ifd end date of the month is saturday then 1 else 0)) (day(numberic value) of the end date - (( no of weeks between firt day of the date supplied and end date)*2)-(if first day of the month is sunday then 1 else 0) - (if date is saturday then 1 else 0))