Connecting Tech Pros Worldwide Forums | Help | Site Map

dates problem

Member
 
Join Date: May 2007
Posts: 121
#1: Jan 12 '08
Hi all
i have access databae in which a table consists of all staff details with dat now if want to retrieve records between 5/01/2008 to 10/01/2008.i dot know the syntax of using between query can u pls help

QVeen72's Avatar
Moderator
 
Join Date: Oct 2006
Location: Bangalore
Posts: 1,385
#2: Jan 12 '08

re: dates problem


Quote:

Originally Posted by charvi

Hi all
i have access databae in which a table consists of all staff details with dat now if want to retrieve records between 5/01/2008 to 10/01/2008.i dot know the syntax of using between query can u pls help

Hi,

Check this :

SELECT * From MyTable Where MYDate Between #05-01-2008#
And #10-01-2008#

Regards
Veena
Member
 
Join Date: May 2007
Posts: 121
#3: Jan 13 '08

re: dates problem


rs.Open "select * from timesheet where date between #" & mskfrom & "#" And "# & mskTo & #", con, adOpenDynamic, adLockOptimistic

I have written this ode but it giv me runtime error.
pls help
Member
 
Join Date: May 2007
Posts: 121
#4: Jan 13 '08

re: dates problem


Quote:

Originally Posted by charvi

rs.Open "select * from timesheet where date between #" & mskfrom & "#" And "# & mskTo & #", con, adOpenDynamic, adLockOptimistic

I have written this ode but it giv me runtime error.
pls help

when writethis code it gives all the records..e if i want to search between 2/01 and 5/01 igives me al recordsof 6/1 ,7/01 so on
Member
 
Join Date: May 2007
Posts: 121
#5: Jan 13 '08

re: dates problem


Quote:

Originally Posted by charvi

when writethis code it gives all the records..e if i want to search between 2/01 and 5/01 igives me al recordsof 6/1 ,7/01 so on

i getthis dateproble when i enter in the form of mm/dd/yyyy in mskedbox1 though i have formatted maskedbox as dd/mm/yyyy why is it pls help
Moderator
 
Join Date: Oct 2006
Location: Australia
Posts: 7,748
#6: Jan 13 '08

re: dates problem


Quote:

Originally Posted by charvi

i getthis dateproble when i enter in the form of mm/dd/yyyy in mskedbox1 though i have formatted maskedbox as dd/mm/yyyy why is it pls help

You need to show us the exact string which is being passed to Access. The fact that the masked edit control shows something in a particular format on the form doesn't tell us anything about what you're getting out of it.

Pretty sure Access demands U.S. date format (MM/DD/YYYY) so the syntax should be something like...

SELECT * From MyTable Where MyDate Between #01/05/2008# And #01/10/2008#

Alternatively, you might avoid the date format issue by using an unambifuous format. That is, one in which the month and day cannot be confused. For example...

SELECT * From MyTable Where MyDate Between #05-Jan-2008# And #10-Jan-2008#
Reply


Similar Visual Basic 4 / 5 / 6 bytes