>-----Original Message-----
>From: Johnny Withers [mailto:joh...@pixelated.net]
>Sent: Wednesday, December 31, 2008 1:13 PM
>To: MySQL General List
>Subject: Compare DATETIME to DATE
>
>Hi,
>I don't quite understand (or even know) what the "proper" way to compare
>a
>DATETIME column to a given DATE value is. I've used various methods but
>I'd
>like to know if there's a better way to compare these values.
>
>Right now I have a query with this in the WHERE clause
>(customer.created_dt
>is a DATETIME):
>
>AND CAST(customer.created_dt AS DATE) BETWEEN '2008-12-30' AND '2008-12-
>30'
>
>This was working (MySQL on Win32) before I moved the database to MySQL
>on
>RHEL 64-bit (5.0.45-log).
>
>Should that work?
>
>I've also done this:
>
>AND customer.created_dt BETWEEN '2008-12-30 00:00:00' AND '2008-12-30
>23:59:59'
>
>That works on both servers, but I really don't want to have to put the
>time
>in there (unless that's the way you are supposed to do this).
>
>I've though about using DATE_FORMAT... not sure about that either.
>
[JS] I've done it with the BETWEEN, when I'm looking for an interval, and
with LEFT(customer.created_dt, 10) = ? if I'm looking for a specific date.
>
>-----------------------------
>Johnny Withers
>601.209.4985
>joh...@pixelated.net




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=arch...@jab.org

Reply via email to