views:

41

answers:

1

I'm trying to select all dates that haven't pass the current date. So for instance, I want to display every date after 2009-10-06 and NOT dates prior 2009-10-06.

+4  A: 

What about something like this, if I understand correctly the question :

select *
from your_table
where your_date_field > '2009-10-06'

As @James Deville stated, you could use some function to get the current date, instead of hard-coding it in the query.

NOW() will get you date+time ; CURDATE() (or its aliases CURRENT_DATE() and CURRENT_DATE) will get you date :

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2009-10-06 19:35:36 |
+---------------------+
1 row in set (0.03 sec)

mysql> select curdate();
+------------+
| curdate()  |
+------------+
| 2009-10-06 |
+------------+
1 row in set (0.01 sec)

So, in your case, something like this should do :

select *
from your_table
where your_date_field > curdate()
Pascal MARTIN
I would replace the '2009-10-06' with the function for the current date. I think it's now(), but I don't know for sure.
James Deville
+1 Though I'm guessing OP is asking for CURRENT_DATE() function in WHERE clause
ChssPly76
@James: now() returns the current time, nanoseconds included, so date fields later today would show up.
Ben S
@James > thanks for your comment ; I've edited my post in consequence -- and shown both now() and curdate()
Pascal MARTIN