I have in filed (short date propeerty) the list of dates, similar:
21/09/2014
02/09/2014
02/09/2014
23/09/2014
...
i need to get the first one date back based MyVar=#25/09/2014#
In english (latest)
in this my case is 23/09/2014
how to with query?
Tks.
Note:
I can have duplicates dates
CHECK one back date
-
- Administrator
- Posts: 78236
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: CHECK one back date
Let's say your table is named MyTable and the field is named MyTable. The SQL to retrieve the date is
strSQL = "SELECT Max(MyDate) AS BackOneDate FROM MyTable WHERE MyDate<#9/25/2014#"
If you want the date 25/09/2014 to be taken from a date variable MyVar, use
strSQL = "SELECT Max(MyDate) AS BackOneDate FROM MyTable WHERE MyDate<#" & Format(MyVar, "mm/dd/yyyy") & "#"
strSQL = "SELECT Max(MyDate) AS BackOneDate FROM MyTable WHERE MyDate<#9/25/2014#"
If you want the date 25/09/2014 to be taken from a date variable MyVar, use
strSQL = "SELECT Max(MyDate) AS BackOneDate FROM MyTable WHERE MyDate<#" & Format(MyVar, "mm/dd/yyyy") & "#"
Best wishes,
Hans
Hans