in reply to Re: DBI: passing undef as an argument
in thread DBI: passing undef as an argument
Like undef, it either means that there isn't a date or that the date is unknown. This is, unfortunately, ambiguous, but can't really be resolved without adding a second "KNOWN BUT EMPTY" (non-)value, leaving NULL to specifically mean "unknown", since dates don't have any real equivalent to zero (for numbers) or empty strings (for text).
Will it be equal, unequal, earlier or later than any other date?
No, it will not be any of these, as you cannot know whether an unknown date is equal, unequal, earlier, or later than any other date.
Can you do date arithmetic on it (what is "NULL" plus three days?)?
No, you cannot calculate "an unknown date plus three days". The result will still be unknown.
Attempting to determine whether a known-nonexistent date is before or after a given date, or the date three days after a known-nonexistent date, is similarly nonsensical. e.g., You can't say whether I was released from prison before or after my 25th birthday or what the date was three days after I met Richard Nixon because I've neither been to prison nor seen Nixon.
If I recall correctly, SQL's semantics for handling NULL are consistent with my interpretation - any logical comparison to NULL will return false1 and NULL + 3 = NULL.
1 Tri-state logic would allow comparisons to more properly return "unknown", but, in boolean logic, "true" and "false" are all we've got to work with and asserting that unknown results are implicitly true would be worse than considering them to be false.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: DBI: passing undef as an argument
by CountZero (Bishop) on Aug 08, 2009 at 21:53 UTC | |
by dsheroh (Monsignor) on Aug 09, 2009 at 09:08 UTC | |
by CountZero (Bishop) on Aug 09, 2009 at 14:10 UTC | |
by dsheroh (Monsignor) on Aug 10, 2009 at 09:53 UTC | |
by CountZero (Bishop) on Aug 10, 2009 at 20:51 UTC | |
| |
by zwon (Abbot) on Aug 08, 2009 at 22:12 UTC | |
by CountZero (Bishop) on Aug 08, 2009 at 22:25 UTC | |
by ikegami (Patriarch) on Aug 12, 2009 at 14:55 UTC | |
by CountZero (Bishop) on Aug 12, 2009 at 19:43 UTC | |
| |
by zwon (Abbot) on Aug 09, 2009 at 19:39 UTC | |
by CountZero (Bishop) on Aug 09, 2009 at 21:11 UTC |