kiranoleti Posted December 12, 2008 Share Posted December 12, 2008 Hi all, I am new to mysql I want to split column name in mysql. Eg: Db 'date' contain 2008-09-12 i want check condition only with year 2008 select * from table where date=2008 in the above how to split the date Sorry for my poor english plz help me Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/136660-solved-how-to-split-a-value-in-mysql/ Share on other sites More sharing options...
waterssaz Posted December 12, 2008 Share Posted December 12, 2008 try using substring() e.g select * from table where substring(date,1,4) = '2008' something like the above should work :-) Quote Link to comment https://forums.phpfreaks.com/topic/136660-solved-how-to-split-a-value-in-mysql/#findComment-713565 Share on other sites More sharing options...
PFMaBiSmAd Posted December 12, 2008 Share Posted December 12, 2008 There is a YEAR() function to do this - http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_year Quote Link to comment https://forums.phpfreaks.com/topic/136660-solved-how-to-split-a-value-in-mysql/#findComment-713604 Share on other sites More sharing options...
waterssaz Posted December 12, 2008 Share Posted December 12, 2008 handy function thats I obviously wasn't aware of. :-) Quote Link to comment https://forums.phpfreaks.com/topic/136660-solved-how-to-split-a-value-in-mysql/#findComment-713654 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.