Datetime NULL Report Parameter

  • I have a datetime report parameter named @due_date with "allow null value" checked. In my where clause I have the following.....

    where rehire_dt = @due_date

    During runtime when I have NULL checked on @due_date, it returns no records. What I need is when NULL is checked, to return every record regardless if rehire_dt is NULL or not.

  • is250sp (4/30/2012)


    I have a datetime report parameter named @due_date with "allow null value" checked. In my where clause I have the following.....

    where rehire_dt = @due_date

    During runtime when I have NULL checked on @due_date, it returns no records. What I need is when NULL is checked, to return every record regardless if rehire_dt is NULL or not.

    One way to fix this:

    where rehire_dt = @due_date or @due_date is null

    Not knowing more about the code, you could also split the code such that if @due_date is not null run the code with your where clause and if i is null to run the code with no where clause.

    This is really a catch all type query and I'm sure someone will come along and post a link to a very good blog post on these types of queries by Gail Shaw. I just don't have that reference handy.

  • Thanks that worked!

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

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