marf Posted June 19, 2007 Share Posted June 19, 2007 This should be fairly simple I think. I want to perform basically this SELECT * FROM database WHERE date='2006-00-00 00:00:00' Will this work? I want to select all the entries where the year is 2006. I'm not sure if this will specifically look for 2006-00-00 00:00:00.. logically to me I would want date='2006-XX-XX XX:XX:XX' but SQL doesn't like that of course. Link to comment https://forums.phpfreaks.com/topic/56234-select-a-year-from-datetime/ Share on other sites More sharing options...
jvrothjr Posted June 19, 2007 Share Posted June 19, 2007 could use where date like '2006%' Link to comment https://forums.phpfreaks.com/topic/56234-select-a-year-from-datetime/#findComment-277730 Share on other sites More sharing options...
akitchin Posted June 19, 2007 Share Posted June 19, 2007 you could extract the date's year using YEAR(), a handy built-in MySQL function among others: SELECT * FROM database WHERE YEAR(date)='2006' more efficient and less prone to odd behaviour than using LIKE. Link to comment https://forums.phpfreaks.com/topic/56234-select-a-year-from-datetime/#findComment-277738 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.