Monday, November 29, 2010

Comparing date with any mysql column


Share at Facebook

You can easily compare dates at SELECT query from mysql.

Using the function, just convert your date into appropriate one. For example using CAST('2010-10-18' as DATE) at select query.


SELECT * from my_table WHERE date_column < CAST('2010-10-18' as DATE)


You can use the date '2010-10-18' from a variable too.




1 comment:

A. Retha said...

This works fine for me without the need to cast. I just put a string date link '2011-02-11' in the query and it just works.