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 |
|
laddu
Constraint Violating Yak Guru
332 Posts |
Posted - 2011-11-29 : 11:42:24
|
| Hi ,Need help to write the script.We are storing User DiseaseDiagnosisDate in yyyy/mmSELECT userid, DiseaseDiagnosisDate FROM userEx:-Userid DiseaseDiagnosisDate 1 2009012 2007013 1993024 198501 Now I need to write a script to pull Duration of disease (less than 6 months vs. greater than or equal to 6 months)Please help. Thanks! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-29 : 11:48:14
|
| [code]SELECT UserId,CASE WHEN DATEDIFF(mm,CAST(CAST(DiseaseDiagnosisDate AS varchar(6)) + '01' as datetime),GETDATE()) <6 THEN 'Less than 6 months'ELSE 'greater than or equal to 6 months'END AS DurationOfDiseaseFROM table[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|