View Full Version : Need query to return last 10 days


sarab99
03-11-2010, 05:35 AM
Hi Expert

I need query to return last 10 days from last date in the table.

I have use the following creteria >=DateAdd("d",-1,Date())-10

but this will return the last date from the current date. I need to return the last 10 days depends on last day in the table.

note the table called table1 and the date filed caled ddate

Thank you

vbaInet
03-11-2010, 06:06 AM
Looks like you're familiar with functions. Lookup the DMax() function as well. Then use BETWEEN with your DateAdd() function. Something like this:

BETWEEN # DMAX() # AND DateAdd()

sarab99
03-11-2010, 07:31 AM
DMAX() dosnt work with query creteria

I got error message.

Could you please advise.

Thank you

vbaInet
03-11-2010, 07:33 AM
Could you show what you wrote and the error message?

SOS
03-11-2010, 07:37 AM
Actually the criteria to get the date range would be:

Between DateAdd("d", -10, Date()) And Date()

SOS
03-11-2010, 07:39 AM
Actually the criteria to get the date range would be:

Between DateAdd("d", -10, Date()) And Date()

Never mind - I didn't read the first part close enough. DMax would be the way to go but you have to include the arguments:

Between DateAdd("d", -10, DMax("[FieldName]", "TableName")) And DMax("[FieldName]", "TableName")

SOS
03-11-2010, 07:44 AM
Instead of uploading it to IMAGE SHACK, could you just upload the image here so those of us at work whose work blocks those public image sites can see what you're posting?

sarab99
03-11-2010, 07:49 AM
Never mind - I didn't read the first part close enough. DMax would be the way to go but you have to include the arguments:

Between DateAdd("d", -10, DMax("[FieldName]", "TableName")) And DMax("[FieldName]", "TableName")


Thank you Mr. SOS it is working now with your great creteria :)


Thanks to others who trying to help.

Regards,

SOS
03-11-2010, 08:01 AM
Glad we could help you out. :)