Forum Moderators: coopster
SELECT * FROM orders WHERE date_purchased = CURDATE()
date_purchased is a field in the table but I was wondering if for some reason it's attempting to match the exact time the order was placed with the current time and that's why it's not returning any results. Any thoughts?
Are you sure that the dates stored in the databases are using the same date format as the date that the function returns? i would say check this before going crazy.
Hope this helps
eelix
Query mysql with the following:
SELECT CURDATE();
This will show you the format that you should store your date in your table.
eelix
eelix
SELECT * FROM orders WHERE (
EXTRACT(MONTH FROM date_purchased) = EXTRACT(MONTH FROM CURDATE())
AND
DAYOFMONTH(date_purchased) = (DAYOFMONTH(CURDATE()) - 1)
)
and it worked. I'm sure there's an easier way but I'm no genius with php so for now it works.