Xtremer360 Posted May 6, 2011 Share Posted May 6, 2011 I'm not quite how I should be doing this but I"m trying to have it select where the events.bookingdate is from any that were taken place in the current year. I"m not sure how to adjust my WHERE clause. WHERE events.bookingDate ="?" Quote Link to comment https://forums.phpfreaks.com/topic/235727-using-current-year-to-match-against-where-clause/ Share on other sites More sharing options...
requinix Posted May 6, 2011 Share Posted May 6, 2011 WHERE events.bookingDate >= "YYYY-01-01" AND events.bookingDate date("Y") will give you the current year. Quote Link to comment https://forums.phpfreaks.com/topic/235727-using-current-year-to-match-against-where-clause/#findComment-1211635 Share on other sites More sharing options...
Xtremer360 Posted May 6, 2011 Author Share Posted May 6, 2011 How would I put the date("Y") into that Quote Link to comment https://forums.phpfreaks.com/topic/235727-using-current-year-to-match-against-where-clause/#findComment-1211637 Share on other sites More sharing options...
Drummin Posted May 6, 2011 Share Posted May 6, 2011 Add above query $yearstart=date("Y-1-1"); $yearend=date("Y-12-31"); And this inside WHERE events.bookingDate >= "$yearstart" AND events.bookingDate <= "$yearend" Quote Link to comment https://forums.phpfreaks.com/topic/235727-using-current-year-to-match-against-where-clause/#findComment-1211644 Share on other sites More sharing options...
mikosiko Posted May 6, 2011 Share Posted May 6, 2011 other option: WHERE DATE_FORMAT(events.bookingDate,'%Y') = DATE_FORMAT(curdate(),'%Y'); Quote Link to comment https://forums.phpfreaks.com/topic/235727-using-current-year-to-match-against-where-clause/#findComment-1211646 Share on other sites More sharing options...
Xtremer360 Posted May 6, 2011 Author Share Posted May 6, 2011 Thank you to both of you. Quote Link to comment https://forums.phpfreaks.com/topic/235727-using-current-year-to-match-against-where-clause/#findComment-1211649 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.