[yunqa.de] SQLite Date() function returns invalid dates.

  • From: Clyde England <clyde@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Mon, 31 May 2010 09:22:58 +0800

Hi,

I realize this is probably more an issue with core SQLite but I did stumble
across it when using SQLiteSpy

I had a database that had some suspect SQL dates in it. To track them down I
was using the following query

Select * from MyTable where Date(MyDate) isNull

For the most part this works just fine. Any invalid formatted dates cause
the Date() function to return a Null value. However, It would appear this
function does not pick up "illogical" dates. For example, we all know that
April only has 30 days in it, but it would appear SQLite thinks otherwise.
Try running the following simple query in SQLiteSpy - I would expect it to
return Null, but instead it returns what it *thinks* is a valid date!

Select Date('2010-04-31')

Bug in core Sqlite or a limitation/quirk of the Date() function?

Thanks
Clyde

Other related posts: