Differences With c-treeSQL Date Types
The following query on a table containing a Date field
can return unexpected rows:
SELECT * FROM myTable WHERE myDate >= '0001-01-01' AND myDate <= '9999-01-01'
However, this query returns the expected set of rows.
SELECT * FROM myTable WHERE myDate >= '1700-03-01' AND myDate <= '9999-01-01'
Why the difference?
The c-tree Plus Date field type stores dates as an
unsigned four byte integer representing the number of days since 02/28/1700.
Hence the first valid date is 03/01/1700. Date values before this date
can result in unexpected results. Thus, when performing c-treeSQL queries
on date data, keep in mind the c-tree Plus 2/28/1700 epoch starting
value.
|