Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
Your query should work.
I just quickly tested it against a datetime field and a varchar field, and mysql does the casting from varchar to datetime automatically.
Code:
mysql> create table dtmTest( dtmReal datetime, strVal varchar(100));
Query OK, 0 rows affected (0.07 sec)
mysql> insert into dtmTest values ('2010-03-09 21:17:30','2010-03-09 21:17:30');
Query OK, 1 row affected (0.04 sec)
mysql> select * from dtmTest;
+---------------------+---------------------+
| dtmReal | strVal |
+---------------------+---------------------+
| 2010-03-09 21:17:30 | 2010-03-09 21:17:30 |
+---------------------+---------------------+
1 row in set (0.00 sec)
mysql> select 'found' from dtmTest where dtmReal < '2010-03-09 22:17:30';
+-------+
| found |
+-------+
| found |
+-------+
1 row in set (0.00 sec)
mysql> select 'found' from dtmTest where strVal < '2010-03-09 22:17:30';
+-------+
| found |
+-------+
| found |
+-------+
1 row in set (0.00 sec)
mysql> select 'found' from dtmTest where strVal < '2010-03-09 20:17:30';
Empty set (0.00 sec)
__________________
Only a biker knows why a dog sticks his head out the window.
|