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 |
JBourne
Starting Member
1 Post |
Posted - 2008-02-27 : 04:29:09
|
Hi, Im still getting to grips with ssrs and the varying ways to script.Im testing on one main column for a datediff with another column, inparticular working out the datediff, Cdate from [O 2 R], as follows;SELECT FNo, [O R], [O 2 R], CDate, DATEDIFF(day, [O 2 R], CDate) AS 'Time Taken'FROM vwAllInfoWHERE (CDate >= @startdate) AND (CDate < @enddate + 1)This works fine, but when [O 2 R] has blanks CDate needs to calculate the DateDiff from column [O R] instead.Ive never really used the CASE statement before and really cant get any kind of CASE test to work. Does anyone have any example script they could provide or give any help please??Many ThanksJB |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-27 : 04:52:08
|
Try:-SELECT FNo, [O R], [O 2 R], CDate, DATEDIFF(day, CASE WHEN [O 2 R] IS NULL OR [O 2 R]='' THEN [O R] ELSE [O 2 R] END, CDate) AS 'Time Taken'FROM vwAllInfoWHERE (CDate >= @startdate) AND (CDate < @enddate + 1) |
 |
|
|
|
|
|
|