Crosstab Missing Values A simple SQL solution for avoiding those pesky missing values you get when you try to use the Microsoft Access crosstab query. |
SELECT DateValue("01" & "/" & Format(Date(),"mm") & "/" & Format(Date(),"yyyy")) AS dDate01, DateValue("01" & "/" & Format(DateAdd("M",1,Date()),"mm") & "/" & Format(DateAdd("M",1,Date()),"yyyy")) AS dDate02, DateValue("01" & "/" & Format(DateAdd("M",2,Date()),"mm") & "/" & Format(DateAdd("M",2,Date()),"yyyy")) AS dDate03, DateValue("01" & "/" & Format(DateAdd("M",3,Date()),"mm") & "/" & Format(DateAdd("M",3,Date()),"yyyy")) AS dDate04, DateValue("01" & "/" & Format(DateAdd("M",4,Date()),"mm") & "/" & Format(DateAdd("M",4,Date()),"yyyy")) AS dDate05, DateValue("01" & "/" & Format(DateAdd("M",5,Date()),"mm") & "/" & Format(DateAdd("M",5,Date()),"yyyy")) AS dDate06, DateValue("01" & "/" & Format(DateAdd("M",6,Date()),"mm") & "/" & Format(DateAdd("M",6,Date()),"yyyy")) AS dDate07, DateValue("01" & "/" & Format(DateAdd("M",7,Date()),"mm") & "/" & Format(DateAdd("M",7,Date()),"yyyy")) AS dDate08, DateValue("01" & "/" & Format(DateAdd("M",8,Date()),"mm") & "/" & Format(DateAdd("M",8,Date()),"yyyy")) AS dDate09, DateValue("01" & "/" & Format(DateAdd("M",9,Date()),"mm") & "/" & Format(DateAdd("M",9,Date()),"yyyy")) AS dDate10, DateValue("01" & "/" & Format(DateAdd("M",10,Date()),"mm") & "/" & Format(DateAdd("M",10,Date()),"yyyy")) AS dDate11, DateValue("01" & "/" & Format(DateAdd("M",11,Date()),"mm") & "/" & Format(DateAdd("M",11,Date()),"yyyy")) AS dDate12 FROM DummyTable; |
SELECT DateAdd("d",-Weekday(Date())+1,Date()) AS dSunday01, DateAdd("d",-Weekday(Date())+8,Date()) AS dSunday02, DateAdd("d",-Weekday(Date())+15,Date()) AS dSunday03, DateAdd("d",-Weekday(Date())+22,Date()) AS dSunday04, DateAdd("d",-Weekday(Date())+29,Date()) AS dSunday05, DateAdd("d",-Weekday(Date())+36,Date()) AS dSunday06, DateAdd("d",-Weekday(Date())+43,Date()) AS dSunday07, DateAdd("d",-Weekday(Date())+50,Date()) AS dSunday08, DateAdd("d",-Weekday(Date())+57,Date()) AS dSunday09, DateAdd("d",-Weekday(Date())+64,Date()) AS dSunday10, DateAdd("d",-Weekday(Date())+71,Date()) AS dSunday11, DateAdd("d",-Weekday(Date())+78,Date()) AS dSunday12, DateAdd("d",-Weekday(Date())+85,Date()) AS dSunday13 |