if with a datepart and a THEN......???

  • can I use something like ...

    if DATEPART(MM,OrderDate) = 12 then (APPT_RPT_APPOINTMENT.DURATION / 60) AS Decschedhours in a select ??

    Thanks in Advance

    Joe

  • If you are trying to generate a column, then you should probably use a CASE expression. An IF statement is used for flow control.

  • Forgot my sample:CASE

    WHEN DATEPART(MM,OrderDate) = 12

    THEN (APPT_RPT_APPOINTMENT.DURATION / 60)

    ELSE NULL

    END AS Decschedhours

  • Thanks

    That works great..

    I even understand it!! 🙂

    Thanks Again

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

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