разница в дате

kvn

programmer
разница в дате

Люди, help:

В чем разница между:
WHERE ... c_time >= 20040301000000 AND c_time < 20040332000000
и
WHERE ... c_time >= 20040301000000 AND c_time < 20040401000000

?
Спасибо.
 

Profic

just Profic (PHP5 BetaTeam)
ЗЫ. Не заметил, что это mysql-время

Насколько я понял, это не mk_time(), с которым можно так извращаться. Mysql, например, при попытке записать такую дату должен записать 00000000000000.
Ну а первое апреля есть первое апреля :)
Разница как видишь большая.
 

tony2001

TeaM PHPClub
Код:
mysql> select date_format('20040332000000',"%Y-%m-%d");
+------------------------------------------+
| date_format('20040332000000',"%Y-%m-%d") |
+------------------------------------------+
| NULL                                     |
+------------------------------------------+
 

Profic

just Profic (PHP5 BetaTeam)
Тони, как всегда, попал точно в цель :)

UPD: О нашел - http://www.mysql.com/doc/en/Date_and_time_types.html
When MySQL encounters a value for a date or time type that is out of range or otherwise illegal for the type (as described at the beginning of this section), it converts the value to the ``zero'' value for that type.
MySQL allows you to store certain ``not strictly legal'' date values, such as '1999-11-31'. The reason for this is that we consider date checking to be the responsibility of the application, not the SQL server. To make date checking faster, MySQL verifies only that the month is in the range from 0 to 12 and that the day is in the range from 0 to 31. These ranges are defined to include zero because MySQL allows you to store dates where the day or month and day are zero in a DATE or DATETIME column. This is extremely useful for applications that need to store a birthdate for which you don't know the exact date. In this case, you simply store the date like '1999-00-00' or '1999-01-00'. Note that if you store dates like these, you should not expect to get correct results for such as DATE_SUB() or DATE_ADD that require complete dates.
 
Сверху