Ashwani Panwar
Ashwani Panwar

Reputation: 4568

Date formatiing not working , mysql

I want to compare event filed of my table with current date. I have dates in event column in m/d/Y format i.e "09/24/2015" .

I am using this query for fetching result which get the records of current date but its returning empty result. I have a record for current date. what is wrong in it ?

SELECT * FROM all_tasks WHERE DATE_FORMAT( CURDATE( ) , '%d/%m/%Y' ) = DATE_FORMAT( date( event ) , '%d/%m/%Y' )

Upvotes: 0

Views: 29

Answers (1)

avi
avi

Reputation: 912

Assuming that you store the event as some sort of string, you can just do simply something like:

select * from all_tasks where DATE_FORMAT(NOW(),'%m/%d/%Y') = all_tasks.event

Here you go a fiddle sample.

Upvotes: 1

Related Questions