modify the where clause as below :
Main Topics
Browse All TopicsI'm trying to write what I thought would be a simple query that will display the data if a date falls between two dates. I started by creating a view that converts my date field to a datetime data type and then join it to my other table. The view itself runs fine. If I don't test the date using the Between line in the query it works fine. However, when I add that line I get the following message:
Msg 245, Level 16, State 1, Line 3
Conversion failed when converting the varchar value '01/06/2010' to data type int.
I'd appreciate any suggestions as to how best to do this so that I can use it in a Reporting Services report.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
In the report, I set both date parameters to DateTime data type. The V.LeaseEffectiveDate is converted to DateTime in the view.
The message I sent previously was from running the query in management studio. I get a similar message when trying run it from Business Intelegence Develepment Studio:
Cannot read the next data row for the data set dsLeaseSigningReport. The conversion of a char data type to a datatime data type resulted in an out-of-range datetime value.
Why do you have a date column not stored in the table as a datetime? Anyways, you need to show how you are converting the value to a datetime - in other words, what does the view look like?
Also, date range filtering is best done using the following:
WHERE dateColumn >= @beginDate AND dateColumn < dateadd(day, 1, @endDate)
And, you want to make sure your date parameters are datetime datatypes and have the time set to midnight (e.g. '20090818 00:00:00.000'). If you use between - you could end up missing rows, or including rows that you don't want. If you end date parameter is '20100106' - that will be implicitly converted to '20100106 00:00:00.000' and using between will include any rows on that date at midnight - but not any that follow midnight.
Finally, you should use a date that is un-ambiguous. Using '01/06/2010' can be interpreted as Jan 06 2010 or Jun 01 2010 depending upon regional settings of the system.
priyananth, when I run your suggestion, I no longer get an error, but it doesn't return any data either (see my comments below). I'm including the code from the view I'm using as well. Hopefully someone will see something in it that I'm doing wrong.
One other note, it's not completely true that I get no data with prirananth's suggestion. If I run it in the data window of Visual Studio (SQL Server Business Intellegence Development Studio) it returns the data I'm expected. However, when I try to preview the report with the same dates, the report is blank. I get the same blank result when running the query in Server managment Studio.
Business Accounts
Answer for Membership
by: aneeshattingalPosted on 2009-08-19 at 15:08:58ID: 25137862
are any of these 'int'
V.LeaseEffectiveDate , @BeginDate , @EndDate