Access Date Function

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

Is there a function in Access that will give me the record
with a date closest to today's date, but has not already
past? I know I could write a formula (Min(Record Date)-
(Date)), but want to know if there is a function that
would perform this task...thanks.
 
Bob said:
Is there a function in Access that will give me the record
with a date closest to today's date, but has not already
past? I know I could write a formula (Min(Record Date)-
(Date)), but want to know if there is a function that
would perform this task...thanks.

Queries and/or Recordsets normally return "Records" whereas Functions
normally return a single value. Do you want an entire record or just a
value from one field?

A Top 1 query with a sort descending on the date field and a criteria of
<Date() should return a record satisfying your criteria.

SELECT TOP 1 YourTableName.*
FROM YourTableName
WHERE YourDateField < Date()
ORDER BY YourDateField DESC
 
Back
Top