Want to use CASE inside DATEDIFF but getting error

  • Need to find the length of stay. Using datediff to find the number of days between admission and discharge and if the admission date is before the select parameter startdate value then use the parameter value.

    Tried this, case statement works fine outside the datediff function but not within it any suggestions.

    datediff(day, case when ia.eventstartdate < @startdate then @startdate else ia.eventstartdate end as 'ia_eventstartdateB' ,id.eventstartdate) as los1,

  • datediff(day, case when ia.eventstartdate < @startdate

    then @startdate

    else ia.eventstartdate end ,id.eventstartdate) as los1,

    Try the above.

  • Thanks for the reply, had managed to figure this out for myself but couldn't remeber my login to update question 🙂

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

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