I am trying to write an ms access SQL query in order to calculate the number of days that have passed since a date in two year periods: "summer" (from 1/6 to 30/09) and non-summer (from 1/1 to 30/05 and from 1/10 to 31/12).
This date is the last "measure" of the product and it could be as old as two years. Then I would like to know, as today, how many days of summer and vice-versa how many days of nonsummer has passed since the product has been measured.
ie. the date is 31/10/2017, I'd like two columns to show summer days passed (=30days*4months in 2018+ 28days in 2019 = 148days) and non-summer days passed ( 7months between Nov17 and may17+ 8 months from Ott18 to May 19 = 450days)
I have been trying using IIF cycles like that one: (ANNI is a variable that means in which year we are 0=this year, 1 past year, etc)
days of non-summer
IIF(ANNI=0; "150"; IIF(ANNI=1;
IIF(G2.DATA_PRODUZ<#01/06/2018#;DateDiff("d",[G2]!
[DATA_PRODUZ],#01/06/2018#)+90+150;
IIF(G2.DATA_PRODUZ>#30/08/18#;DateDiff("d",[G2]!
[DATA_PRODUZ],#31/12/2018#)+150));"etc");)
But it won't work and it does it would only work this summer. I'd accept any ideas.