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? Quote 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 Quote 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(). Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.