tags:

views:

37

answers:

2

How to pass the current date to a query in mysql like such query:

select from Dailytimesheet dailytimesheet where dailytimesheet.TrackingDate="2010-05-03"
A: 

you can use the NOW() function within your SQL query to get the current timestamp.

Derek P.
+3  A: 

In MySQL, you can use CURRENT_DATE to get the current date.

mysql> select CURRENT_DATE;
+--------------+
| CURRENT_DATE |
+--------------+
| 2010-05-03   |
+--------------+
1 row in set (0.08 sec)

Using NOW() works as well, but gets you the current date and time as a timestamp value. You can truncate it like DATE(NOW()), but CURRENT_DATE avoids the function call.

Ian Clelland