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 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 :-) 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 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. :-) 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
Archived
This topic is now archived and is closed to further replies.