Access Query - Between Operator showing additional data

  • Thread starter Sivakumar V via AccessMonster.com
  • Start date
S

Sivakumar V via AccessMonster.com

I am using vb-access for my application. In one report i am using between operator in SQL to fetch data from access database.

the following is the query:

SQL = "Select * from tbl1 where unit =1 " _
& " and utdt between #" & frmdt & "#" _
& " and #" & todt & "#"

set sRs = dbCN.execute(sql)

if i am giving 31/12/2004 as from date and 1/1/2005 as to date working perfectly.

if i am giving 31/12/2004 and 2/1/2005 as a from and to date because of 2/1/2005 is a holiday the query fetching beyond the limit of "todate"

what is the solution ???
 
V

Van T. Dinh

The problem is that JET uses the US date format for hash(#)-delimited date
values and #02/01/2005# will be interpreted as 01/Feb/2005.

Since it is likely that you use a different date format, you need to format
the date so that it is fed to JET in the format "#mm/dd/yyyy#".

--
HTH
Van T. Dinh
MVP (Access)




Sivakumar V via AccessMonster.com said:
I am using vb-access for my application. In one report i am using between
operator in SQL to fetch data from access database.
the following is the query:

SQL = "Select * from tbl1 where unit =1 " _
& " and utdt between #" & frmdt & "#" _
& " and #" & todt & "#"

set sRs = dbCN.execute(sql)

if i am giving 31/12/2004 as from date and 1/1/2005 as to date working perfectly.

if i am giving 31/12/2004 and 2/1/2005 as a from and to date because of
2/1/2005 is a holiday the query fetching beyond the limit of "todate"
 

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