CHECK one back date

User avatar
sal21
PlatinumLounger
Posts: 4334
Joined: 26 Apr 2010, 17:36

CHECK one back date

Post by sal21 »

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) :grin:
in this my case is 23/09/2014

how to with query?

Tks.

Note:
I can have duplicates dates

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: CHECK one back date

Post by HansV »

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") & "#"
Best wishes,
Hans