Darkmatter5 Posted October 30, 2008 Share Posted October 30, 2008 If my table has this: item_id year 1 2008-10-15 2 2007-10-15 how can I select only the first 4 digits of the year column? Link to comment https://forums.phpfreaks.com/topic/130740-solved-how-to-select-a-portion-of-a-field-in-a-query/ Share on other sites More sharing options...
Darkmatter5 Posted October 30, 2008 Author Share Posted October 30, 2008 Nevermind, figured it out. SELECT MID(year,1,4) FROM items Link to comment https://forums.phpfreaks.com/topic/130740-solved-how-to-select-a-portion-of-a-field-in-a-query/#findComment-678484 Share on other sites More sharing options...
fenway Posted October 30, 2008 Share Posted October 30, 2008 Use YEAR()... or EXTRACT() or DATE_FORMAT(). Link to comment https://forums.phpfreaks.com/topic/130740-solved-how-to-select-a-portion-of-a-field-in-a-query/#findComment-678540 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.