Passing null values to Date parameter

  • Add "AND @DTStart IS NULL" before the "OR" and see if that does what you need.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Hi

    Thanks for your time.

    I tried in below 2 ways.

    AND ((@DTStart IS NULL )OR (lft.Expiry_Date BETWEEN @DTStart AND @DTEnd))

    AND ((@DTStart IS NULL AND @DTEnd IS NULL )OR (lft.Expiry_Date BETWEEN @DTStart AND @DTEnd)).

    This time I am not getting null values when I selected null.

    Can you please suggest me?

    Thanks

  • Hi

    I tried in different ways and got the solution finally.

    Solution:

    AND (

    (@Expiry = 'In Range' AND lft.Expiry_Date BETWEEN @DTStart AND @DTEnd)

    OR (@Expiry = 'No Expiry' AND lft.Expiry_Date IS NULL)

    )

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

    Anitha

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

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