Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query on date

Status
Not open for further replies.

McFestoe

Technical User
Dec 16, 2003
145
GB
I have a query that uses the following to sort records >=DateAdd("d",-21,Date())

This lists all records that have a renewal date within the next 21days, this works fine but it brings up records that are previous than todays date, is there a way to stop it bringing up the records before todays date.
 
Code:
And #YourDateField# >= Date()
perhaps?

Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
That's what I get for not previewing my posts, the last sentence is supposed to read:

That should do it, or you could use BETWEEN perhaps?

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Thanks, just needed a little help could not see how to do it, ended up with

>=DateAdd("d",-21,Date()) And >=Date()

Will make shure it returns what i need.

Thanks

 
Looks good to me.

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
>=DateAdd("d",-21,Date()) And >=Date()
To get same resulset simply use this:
>=Date()

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
How so PHV?

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
I see what you mean, I thought it was a strange way that the OP was doing it, from the suggestion I would think we'd want:
Code:
<=DateAdd("d",21,Date()) and >=Date()

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
all records that have a renewal date within the next 21days
In the criteria cell of [renewal date]:
Between Date() And Date()+21

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks Guys for the help.

PHV just reading your last post, i cant seam to get my head around it, iam right in thinking

Between Date() And Date()+21 means

between current date and current date +21

Sorry for that i know see what you where getting at, will try that approach as well.



 
Sorry for the previous post, iam daft, thanks for showing me another way.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top