Date format in query

aman

Registered User.
Local time
Today, 12:25
Joined
Oct 16, 2008
Messages
1,251
Hi Guys

I am writng code in excel VbA that will fetch data from Access table.

04/03/2015 means 4th March 2015 so if I write the sql query as below then it doesn't pull anything from access table.
Code:
strsql = "SELECT DISTINCT printpoolno FROM tblmaster where username='" & Application.UserName & "' AND Date1=#" & Format("04/03/2015", "mm/dd/yyyy") & "#"
    MsgBox strsql
Please suggest me what shall I do?
 
Try:

Format(DateValue("04/03/2015"), "mm/dd/yyyy")

It probably doesn't recognise the string as a date in order to format it appropriately.
 
It worked fine. Thanks Mile-O
 

Users who are viewing this thread

Back
Top Bottom