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 |
|
w1102157
Yak Posting Veteran
80 Posts |
Posted - 2012-08-02 : 05:32:32
|
| Hi Guys ,i am trying to find out the number of days between two dates and i am running the following queryDATEDIFF(d, ElementStartDate, ElementEndDate)however can i alter thsi query to say if the ElementEndDate is -1 then state no end date? |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2012-08-02 : 05:57:23
|
| For the datediff to work you need to compare two columns with data type date/datetime (unless you're using varchar and relying on implicit conversion which you really shouldn't), and -1 is not a valid date/datetime value.- LumbagoMy blog-> http://thefirstsql.com |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-02 : 09:44:24
|
quote: Originally posted by w1102157 Hi Guys ,i am trying to find out the number of days between two dates and i am running the following queryDATEDIFF(d, ElementStartDate, ElementEndDate)however can i alter thsi query to say if the ElementEndDate is -1 then state no end date?
Isnt ElementEndDate a datetime field? How can it have a value of -1?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|