Friday, December 26, 2008

VB.net SQL statement for SELECT * WHERE mydate = ?

It is sometimes frustrating to find out that the date function is not working correctly when you are trying to retrieve date from the database in vb.net with Access database. I tried to get the data for nearly two days but failed to get it.

The answer to that was very simple

In Access Database, make sure that the date field is set to Short Date and the Format is "dd/mm/yyyy" or what ever you like.

Then use your normal SQL statement for date and it will work

I have used the following

SELECT * FROM tbl_Student WHERE Enroll_Date = #" & me.cboEnrollDate & "#"

No comments: