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 |
|
Petronas
Posting Yak Master
134 Posts |
Posted - 2011-05-21 : 18:38:56
|
| Hi, I have to get the following: If Datediff (getdate(), orderdate) =18 then 'Overdue by (18-5) daysElse if Datediff(getdate(),Orderdate)=16 then 'Overdue by (16-5) daysI don't know how to get the variable. Appreciate any help in this.Thanks,Petronas |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-05-21 : 22:07:03
|
| You can only get the result from one row of the table in a variableselect @v = case when Datediff(dd,orderdate,getdate()) >=18 then 'Overdue by (18-5) days'when Datediff(dd,orderdate,getdate()) >=16 then 'Overdue by (16-5) days'endfrom tblwhere orderid = xxx==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
Petronas
Posting Yak Master
134 Posts |
Posted - 2011-05-22 : 09:38:08
|
| Thank you for for help!Thanks,Petronas |
 |
|
|
|
|
|