Returning rows where [date field] + 62 >=Date()

laurastreng

Board Regular
Joined
Apr 1, 2004
Messages
58
Hi-
I am trying to convert a query that I run in AQT that uses this date calculation to pull back rows where the time span between the two dates is =>62 days, and that resulting date is => current date.
Here is the code in my sql query:
AND (Date(TMD1.D_REQUEST + 62 Days)>= Current Date)

I have been trying to work with DateAdd and/or DateDiff but what I end up with is old dates along with the records I actually want

examples of my useless uses :-)
I pare down the possible results right now by stating that D_REQUEST is > 03/01/11 but I don't really want do this - but this is bonus if I can change that date need. I can make it a date prompt I suppose....... but again, that's not my priority right now.

62DaysPostReqDt: DateAdd("d",62,[D_REQUEST])

#DaysUntil62Days: DateDiff("d",Date(),[D_REQUEST]+62)

You who are more savvy than I can see how I'd return negative numbers and old dates in addition to dates that are >=Date()

How do I work in the sql
AND (Date(TMD1.D_REQUEST + 62 Days)>= Current Date)

into the Access code? So that the date resulting from adding 62 days to the date in D_REQUEST is => Date()

Thank you in advance!
Laura
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Laura

It's not really clear what dates you want to use.

Also what is the 'resulting date'?

Is it the later of the 2 dates you want to check are >=62 days apart?
 
Upvote 0
If TMD1.D_REQUEST is already a date field, you don't need to use any special functions on it. You should just be able to use:
Code:
WHERE ...
AND (([TMD1].[D_REQUEST] + 62) >= Date())
 
Upvote 0
I'll try to explain a little more clearly.
The desired end result is a list that shows cases where the time span between the request date, [D_REQUEST] and the current or near future date is 62 days. So I'm trying to return rows where the length of time is between 62 and 72 days, where 62 days is the difference between the D_REQUEST field and the current date, and then the remaining rows show what future date meets the 62 days date difference.

D_REQUEST Today #DaysSinceRequest 62DaysPostReqDt #DaysUntil62Days
6/10/2011 8/11/2011 62 8/11/2011 0
6/13/2011 8/11/2011 59 8/14/2011 3
etcetera..............

what I'm ALSO getting though are rows where the #DaysSinceRequest is >62, and #DaysUntil62Days ranges from -100 to 1.

All I want are results like what I've shown, so the D_REQUEST field should actually be <=62 days from today. Maybe I'm working with the wrong field.

Here are the present formulas that result in the above:
#DaysSinceRequest: DateDiff("d",[D_REQUEST],Date())

62DaysPostReqDt: DateAdd("d",62,[D_REQUEST])

#DaysUntil62Days: DateDiff("d",Date(),[D_REQUEST]+62)

Thanks
Laura
 
Upvote 0
Laura

So you want to find 62 days after the request date.

If that is today or in the future return the record.

Did you try Joe's suggestion?

I think that's what you need.
 
Upvote 0

Forum statistics

Threads
1,224,504
Messages
6,179,144
Members
452,891
Latest member
JUSTOUTOFMYREACH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top