Null Date

  • I have a query that is looking at two dates, Case when Date A > Date B, Date A, Else B.  This works fine as long as one is not null, I have tweaked my case statement to fix this, that was simple enough, what I would like to know is why does SQL not understand toss out the null date and default to the non null date?

  • Because NULL is not equal to 1900/01/01.  NULL is not even equal to NULL.

     

    May I suggest a default value of the parameter in the proc?  That would simplify the case statement a bit.

  • Basically, NULL means 'I don't know what this value is'. If you don't know what the value is, how can you compare it (, =, =>, =<, etc) to another value?

    -SQLBill

  • And, you still need to determine.... is null a date way back in the past or a date in the future?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

  • Exactly the point of a NULL.  We don't know the information.

    Now we could get started on the fact that we could know that this information does not exists but that's another story .

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

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