Question Locked

Date Query In VB6 with MS-Access

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

This is Run Accurately and Display Accurate Rcords in Grid

In Table Date Field is as: 25/02/08,25/03/08
Date Format : dd/mm/yy (Short Date)

"SELECT Name, BookingDate From Passenger WHERE BookingDate Between #2/25/2008# And Date()"

But This is Not Run.

"SELECT Name, BookingDate From Passenger WHERE BookingDate Between #" & CDate(DTPicker1) & "# And Date()"

This Query Display only one empty record in Grid.
No Error
No Result
Why ?
Please Help Me.

4 replies

by tony hopkinson

is a the name of a dateTimePicker instance on your form.

So if I remeber my VB6

SELECT Name, BookingDate From Passenger WHERE BookingDate Between #" & Format(DTPicker1.Value,"mm/dd/yy") & "# And Date()"

As a PS you should not be be using that format except to display the date.

Use YYYY-MM-DD or even YYYYMMDD in queries, you don't want to have to deal with is 2/4/2008 the 2nd of the 4th or the 4th of the 2nd. Not to mention two digit years.

May not matter just how but best to learn good habits early.

by kcdeewana

"select * from GD" _
& "where GDDATE between #" & Format(dtpFrom.Value, "MM/DD/YYYY") & "#" _
& "and #" & Format(dtpTo.Value, "MM/DD/YYYY") & "#"
After making this query, vb display me an error msg.
The error msg is : syntax error in FROM clause.

by suraj dagar

After this Query if You close your record then this type of problem come..

This discussion is closed to new replies.