rainbowruthm
New member
- Local time
- Today, 15:21
- Joined
- Dec 23, 2008
- Messages
- 7
Hi,
I have spent a long time making a query that calculates samples due to be sent out after one month then every two months for two years for a study I am setting up.
The query is as follows:
FUDueThisWkorEND: IIf(DatePart("ww",(IIf([Follow-upMonth]<=1,((DateAdd("m",([Follow-upMonth]+1),[Baseline]))),IIf([Follow-upMonth]>23,"11/11/1111",((DateAdd("m",([Follow-upMonth]+2),[Baseline])))))))=DatePart("ww",Date()) And Year((IIf([Follow-upMonth]<=1,((DateAdd("m",([Follow-upMonth]+1),[Baseline]))),IIf([Follow-upMonth]>23,"11/11/1111",((DateAdd("m",([Follow-upMonth]+2),[Baseline])))))))=Year(Date()),"Follow-upDue",Null)
Where [Baseline] is the date of the first sample and [Follow-upMonth] is the months after baseline that the previous sample can be (which is 0, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22 and 24).
To make the Follow-upDue statement come in the current week I used the microsoft help idea -
Contain dates that fall during the current week
DatePart("ww", [SalesDate]) = DatePart("ww", Date()) and Year( [SalesDate]) = Year(Date())
The problem is, that we actually need to know a sample is due the week before and not the current week, as that is leaving it too late.
I would therefore like to change my coding into this format (again from the microsoft help):
Contain dates that fell during the previous week
Year([SalesDate])* 53 + DatePart("ww", [SalesDate]) = Year(Date())* 53 + DatePart("ww", Date()) - 1
But it is too complicated and I can't...
Would anyone be able to change my query so it showed dates in the previous week rather than the current week??
THANKS
I have spent a long time making a query that calculates samples due to be sent out after one month then every two months for two years for a study I am setting up.
The query is as follows:
FUDueThisWkorEND: IIf(DatePart("ww",(IIf([Follow-upMonth]<=1,((DateAdd("m",([Follow-upMonth]+1),[Baseline]))),IIf([Follow-upMonth]>23,"11/11/1111",((DateAdd("m",([Follow-upMonth]+2),[Baseline])))))))=DatePart("ww",Date()) And Year((IIf([Follow-upMonth]<=1,((DateAdd("m",([Follow-upMonth]+1),[Baseline]))),IIf([Follow-upMonth]>23,"11/11/1111",((DateAdd("m",([Follow-upMonth]+2),[Baseline])))))))=Year(Date()),"Follow-upDue",Null)
Where [Baseline] is the date of the first sample and [Follow-upMonth] is the months after baseline that the previous sample can be (which is 0, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22 and 24).
To make the Follow-upDue statement come in the current week I used the microsoft help idea -
Contain dates that fall during the current week
DatePart("ww", [SalesDate]) = DatePart("ww", Date()) and Year( [SalesDate]) = Year(Date())
The problem is, that we actually need to know a sample is due the week before and not the current week, as that is leaving it too late.
I would therefore like to change my coding into this format (again from the microsoft help):
Contain dates that fell during the previous week
Year([SalesDate])* 53 + DatePart("ww", [SalesDate]) = Year(Date())* 53 + DatePart("ww", Date()) - 1
But it is too complicated and I can't...
Would anyone be able to change my query so it showed dates in the previous week rather than the current week??
THANKS