Click here to Skip to main content
14,694,039 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,
I wrote a query to get data between two dates (SSCE database) in the following way.

Where DTE between @D1 and @D2

it does not work. Then I tried

Where DTE between @#D1# and @#D2#

But it also does not show the data between I gave the dates.
D1 and D2 get dates from two DateTimePickers (formated to short date)

Please advise.
Thanks
Furqan
Posted
Updated 4-Mar-11 7:28am
v2
Comments
Henry Minute 4-Mar-11 12:17pm
   
To get help more quickly, you should expand on 'it does not work'.

What does that mean?

Did it throw an exception?
Did it return the wrong data? If so, in what way was it wrong?
Furqan Sehgal 4-Mar-11 13:10pm
   
it threw wrong date. I asked for data between 01/01/2011 and 06/01/2011, it returned data of 2012 as well.
milenalukic 5-Mar-11 18:09pm
   
I had an issue a long time ago using between but cannot remember what the outcome was back then. Now I always use:

where DTE>=@FromDate and DTE<=@ToDate

and also make sure that dates are in the same format DD/MM/YYYY etc

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900