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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find closest past date 3

Status
Not open for further replies.

SMHSleepy

Technical User
Sep 8, 2009
174
CA
Hey there. I have a table populated with a bunch of dates. Can anyone suggest a simple way to find the closest historic (i.e. past) date to the current date? Thanks.
 



hi,

having Max(historic) < Date()

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 


hi,

having max(historic) < date()

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I'm getting a sub or function not defined error on the "max" code.
 

It is because if you state: "I have a table populated with a bunch of dates." it is assumed you are talking about the data base, probably Access, so "having max(historic) < date()" would be a part of an SELECT Sql statement.

Is that right, Skip?

Have fun.

---- Andy
 
Did you mean DMax? Tried that too but doesn't work with the <date() part.
 
Thanks for the clarification Andy. Even so, doesn't MAX return the number of records as apposed to DMAX which returns the maximum record?
 

Doesn't your original post indicate that you want the maximum date that is less than the current date?


Randy
 
Yes, the maximum date from the dates listed in my table which is less than the current date. I think I just need more detailed instructions or time to clear my head and figure it out.
 
SQL code:
SELECT Max(yourDateField)
FROM yourTable
WHERE yourDateField<Date()

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 


Yes, part of a query SQL.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Many thanks all, my sql and vba were all screwed up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top