Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
gavakie
Posting Yak Master
221 Posts |
Posted - 2010-04-13 : 10:58:36
|
| Declare @lngStoreId INT, @dtmReportStart datetimeSet @lngStoreId = 10988Set @dtmReportStart = Cast('2010-02-01' as datetime)Select dtmDateVehPurchased,*From tblVehicle vINNER JOIN tblCustomer c on c.lngCustomerId=v.lngCustomerIdWHERE lngStoreId = @lngStoreId and dtmDateVehPurchased > @dtmReportStartIf I run this I get no results, if I change the where clause to thisnd dtmDateVehPurchased > Cast('2010-02-01' as datetime)My results work, any ideas> |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-04-13 : 13:14:06
|
| Looks like the second cast may be returning Jan 2 rather than Feb 1. What date values does it return, and what date values does the column contain? eg, are there any records > 1 Feb 2010, and does the query that returns some records return any of these?------------------------------------------------------------------------------------Any and all code contained within this post comes with a 100% money back guarantee. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-14 : 00:04:03
|
| do a Select @dtmReportStart before select staement to see what value its returning------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|