M
mewins
I am trying to use DateDiff to autocalculate some dates, but it returns dates
for past years that I don’t need. The query is listed below. What I want to
happen is for the user to enter in the date range and have the query
automatically find clients in particular contracts who will, within the
specified date range, be hitting their 30th, 90th, 120th, 180th day, or 8th
month, of being in that contract (based on that client’s arrival date, or
date of asylum if the client has that date listed). I am getting the
intervals right in general, but for clients who were enrolled in past years
come up in the query. I could fix this by only allowing clients who are
marked as being active show up, but sometimes clients go inactive and I need
those clients to show up in the specified dates. Sorry if it’s a little
confusing. Any ideas? Thanks!
SELECT [firstname] & " " & [lastname] AS [Full Name], tblContract.CotrName,
tblContract.ContrStart, tblContract.ContrEnd, tblMainClientInfo.CaseMgr,
tblMainClientInfo.AsylumDate, tblMainClientInfo.ArrivDate, IIf([asylumdate]
Is Null,(DateAdd("d",30,[arrivdate])),DateAdd("d",30,[asylumdate])) AS [30
Day Report Date], IIf([asylumdate] Is
Null,(DateAdd("d",30,[arrivdate])),DateAdd("d",90,[asylumdate])) AS [90 Day
Report Date], IIf([asylumdate] Is
Null,(DateAdd("d",30,[arrivdate])),DateAdd("d",120,[asylumdate])) AS [120 Day
Report Date], IIf([asylumdate] Is
Null,(DateAdd("d",30,[arrivdate])),DateAdd("d",180,[asylumdate])) AS [180 Day
Report Date], IIf([asylumdate] Is
Null,(DateAdd("d",30,[arrivdate])),DateAdd("m",8,[asylumdate])) AS [8 Month
Report Date]
FROM tblMainClientInfo INNER JOIN tblContract ON tblMainClientInfo.ClientID
= tblContract.ClientID
WHERE (((tblContract.CotrName)="rcm" Or (tblContract.CotrName)="mg") AND
((tblContract.ContrStart) Is Not Null) AND ((tblContract.ContrEnd) Is Null))
ORDER BY [firstname] & " " & [lastname];
for past years that I don’t need. The query is listed below. What I want to
happen is for the user to enter in the date range and have the query
automatically find clients in particular contracts who will, within the
specified date range, be hitting their 30th, 90th, 120th, 180th day, or 8th
month, of being in that contract (based on that client’s arrival date, or
date of asylum if the client has that date listed). I am getting the
intervals right in general, but for clients who were enrolled in past years
come up in the query. I could fix this by only allowing clients who are
marked as being active show up, but sometimes clients go inactive and I need
those clients to show up in the specified dates. Sorry if it’s a little
confusing. Any ideas? Thanks!
SELECT [firstname] & " " & [lastname] AS [Full Name], tblContract.CotrName,
tblContract.ContrStart, tblContract.ContrEnd, tblMainClientInfo.CaseMgr,
tblMainClientInfo.AsylumDate, tblMainClientInfo.ArrivDate, IIf([asylumdate]
Is Null,(DateAdd("d",30,[arrivdate])),DateAdd("d",30,[asylumdate])) AS [30
Day Report Date], IIf([asylumdate] Is
Null,(DateAdd("d",30,[arrivdate])),DateAdd("d",90,[asylumdate])) AS [90 Day
Report Date], IIf([asylumdate] Is
Null,(DateAdd("d",30,[arrivdate])),DateAdd("d",120,[asylumdate])) AS [120 Day
Report Date], IIf([asylumdate] Is
Null,(DateAdd("d",30,[arrivdate])),DateAdd("d",180,[asylumdate])) AS [180 Day
Report Date], IIf([asylumdate] Is
Null,(DateAdd("d",30,[arrivdate])),DateAdd("m",8,[asylumdate])) AS [8 Month
Report Date]
FROM tblMainClientInfo INNER JOIN tblContract ON tblMainClientInfo.ClientID
= tblContract.ClientID
WHERE (((tblContract.CotrName)="rcm" Or (tblContract.CotrName)="mg") AND
((tblContract.ContrStart) Is Not Null) AND ((tblContract.ContrEnd) Is Null))
ORDER BY [firstname] & " " & [lastname];