What is the largest date PHP and MySQL recognizes?
I mean, I have different values for different timeline and I want to make them all as BETWEEN
selects in MySQL, like this:
SELECT * FROM table WHERE date BETWEEN '2011-10-01' AND '2011-10-02';
SELECT * FROM table WHERE date BETWEEN '2011-10-03' AND '2011-10-10';
etc.
To get all options, was thinking of something like this:
SELECT * FROM table WHERE date BETWEEN '0000-01-01' AND '2011-10-01';
SELECT * FROM table WHERE date BETWEEN '2011-10-02' AND '2011-10-10';
SELECT * FROM table WHERE date BETWEEN '2011-10-11' AND '9999-12-31';
Will this always work or is there a chance the code might break at some point?
DateTime. MinValue is 0001-01-01 00:00:00 , but the minimum supported value for a DATETIME column is 1000-01-01 00:00:00 . In many versions of MySQL Server, you can successfully insert this value; however, it is not officially supported. By default, inserting DateTime.
MySQL retrieves and displays DATETIME values in ' YYYY-MM-DD hh:mm:ss ' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59' . The TIMESTAMP data type is used for values that contain both date and time parts.
Here is the different date range , depends on your column type:
As per docs
The DATE type is used for values with a date part but no time part. MySQL retrieves and displays DATE values in 'YYYY-MM-DD' format. The supported range is '1000-01-01' to '9999-12-31'.
The DATETIME type is used for values that contain both date and time parts. MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.
The TIMESTAMP data type is used for values that contain both date and time parts. TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.
The DATE type is used for values with a date part but no time part. MySQL retrieves and displays DATE values in 'YYYY-MM-DD' format. The supported range is '1000-01-01' to '9999-12-31'.
taken from http://dev.mysql.com/doc/refman/5.5/en/datetime.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With