Date in code to SQL - something wrong, but what?

M

Makelei

Hi,
please help me!

I have made a VBA code to form SQL:
This is working OK:
BLASql = BLASql & " HAVING (((Calendar.Day) Between #25/7/2007# And
Date()+1));"

But I need to have date changing (=> wkStartBLA), so this is the latest one
and is NOT working:
BLASql = BLASql & " HAVING (((Calendar.Day) Between #" & Format(wkStartBLA,
"dd/mm/yyyy") & "# And Date()+1));"

I do hate these date formats! Could you please help me to fix this - thanks.
MakeLei
 
A

Alex Dybenko

Hi,
in order to be properly recognized you need to pass date as #mm/dd/yyyy#, so
your SQL should look like:

BLASql = BLASql & " HAVING (((Calendar.Day) Between #" & Format(wkStartBLA,
"mm\/dd\/yyyy") & "# And #" & format(Date()+1,"mm\/dd\/yyyy") & "# ));"

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com
 
M

Makelei

Hi & thanks Alex once again ;o)
I was quite close in my experiments, but not quite there - now it works.
BR
MakeLei
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top