Re: error in comparing date with datetime
Sinisa Milivojevic <[email protected]>
| Newsgroups | gmane.comp.db.mysql.bugs |
|---|---|
| Message-ID | <[email protected]> |
Paul B van den Berg writes: > Description: > a datetime with no time-information should be equal to a date > if de date-parts are identical. > How-To-Repeat: > create table t (d1 date, d2 datetime); > insert into t values (20040320,20040320); > select d2=d1 from t; > +-------+ > | d2=d1 | > +-------+ > | 0 | > +-------+ > Fix: > select d2=d1+interval 0 second from t; > +-------------------------+ > | d2=d1+interval 0 second | > +-------------------------+ > | 1 | > +-------------------------+ > Hi! Yes, the above is expected behaviour. You can not compare different column types unless you do some type of conversion. It can be done as above or with CAST() commands. -- Sincerely, -- For technical support contracts, go to https://order.mysql.com/?ref=msmi __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Mr. Sinisa Milivojevic <[email protected]> / /|_/ / // /\ \/ /_/ / /__ MySQL AB /_/ /_/\_, /___/\___\_\___/ Full time Developer and Support Coordinator <___/ www.mysql.com Larnaca, Cyprus Meet the MySQL at User Conference ! (April 14-16, 2004) http://www.mysql.com/uc2004/ -- MySQL Bugs Mailing List For list archives: http://lists.mysql.com/bugs To unsubscribe: http://lists.mysql.com/[email protected]