[thelist] ASP and SQL and dates

Tab Alleman Tab.Alleman at MetroGuide.com
Fri Aug 15 09:58:23 CDT 2003


darren wrote:
> On Friday, August 15, 2003 at 14:27, Lightening wrote:
> 
>> This is similar to a question I asked earlier except that was an
>> integer, this is a date. You guys recommended CInt (which fixed it)
>> back then, so I tried CDate now, with no result. This code finds no
>> records, although there are records there.
> 
>> Can som one help me with this?
> 
> try wrapping your date in #'s...
> 
>    sql="SELECT HolidayId, HolidayName,  TimeOpen, TimeClose, HDate "
>        &_ " from HolidayTable where hdate >= #" &
>        cdate(firstDateOfMonth) &_ "# and hdate <= #" &
> cdate(lastDateOfMonth) & "#" 
> 
> should work for access...

You also might want to use the BETWEEN keyword for dates instead of the
<= and >=:

...WHERE hdate BETWEEN #date1# AND #date2#...


More information about the thelist mailing list