why can't i add a date dif with case??

  • Don't laugh... too hard....

    Why can't I add the DATEDIFF(day,week1start,week1end) AS week1dif to calc the above two case statements?

    Thanks

    CASE

    WHEN appointment.effdate <= @enddate-27 and APPOINTMENT.Expdate between @enddate-27 and @enddate-21 THEN DATEADD(day,-27,@enddate)

    when APPOINTMENT.EffDate < @enddate -27 and APPOINTMENT.Expdate> @enddate-21 then DATEADD(day,-27,@enddate)

    when APPOINTMENT.EffDate between @ENDdate-27 and @enddate-21 then APPOINTMENT.EffDate

    end as week1start,

    Case

    when APPOINTMENT.EffDate<= @enddate-27 And APPOINTMENT.Expdate between @enddate-27 and @enddate-21 Then APPOINTMENT.Expdate

    when APPOINTMENT.EffDate < @enddate-27 and APPOINTMENT.Expdate > @enddate-21 then DATEADD(day,-21,@enddate)

    when APPOINTMENT.EffDate between @enddate-27 and @enddate-21 and APPOINTMENT.Expdate > @enddate-21 then DATEADD(day,-21,@enddate)

    end as week1end,

    DATEDIFF(day,week1start,week1end) AS week1dif

  • I've replied to your other post:

    http://www.sqlservercentral.com/Forums/Topic1420526-391-1.aspx

    ---------------------------------------------------------

    It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
    David Edwards - Media lens[/url]

    Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
    Howard Zinn

  • Thanks Abu really appreciate it, I really have to stop thinking crystal syntax!!

  • You're welcome 😉

    ---------------------------------------------------------

    It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
    David Edwards - Media lens[/url]

    Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
    Howard Zinn

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply