Date Expression

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I get a record with a lots of services date to show me ONLY the
closest date to today.

Thank you
 
Define what you mean by "closest date to today" -- can that date be later
than today? or only earlier than today? How is your table structured -- the
question suggests that you have many fields with dates in them for each
record?
 
The closest date earlier than today

Ken Snell said:
Define what you mean by "closest date to today" -- can that date be later
than today? or only earlier than today? How is your table structured -- the
question suggests that you have many fields with dates in them for each
record?
 
You aren't telling us anything about your table setup, so all I can do is
provide you with a generic query:

SELECT TableName.PrimaryKeyFieldName, TableName.DateField
FROM TableName
WHERE TableName.DateField IN
(SELECT Max(T.DateField)
FROM TableName AS T
WHERE T.DateField < TableName.DateField AND
T.PrimaryKeyFieldName = TableName.PrimaryKeyFieldName);
 
Back
Top