suyesh.amatya Posted August 7, 2008 Share Posted August 7, 2008 2008-08-06 10:43:50 this is the format that date is stored in mysql table. Now after fetching from the database,how can i only extract only the year or month portion from this. Quote Link to comment https://forums.phpfreaks.com/topic/118570-solved-date-format/ Share on other sites More sharing options...
MasterACE14 Posted August 7, 2008 Share Posted August 7, 2008 you could use substr(); Quote Link to comment https://forums.phpfreaks.com/topic/118570-solved-date-format/#findComment-610444 Share on other sites More sharing options...
suyesh.amatya Posted August 7, 2008 Author Share Posted August 7, 2008 SELECT *,extract(year from date_of_post)as year from table The format is EXTRACT(date_type FROM date_column) where date_type is the component to retrieve and date_column is the name of the column from which to extract data This query gives the desired result,without the overhead of string manipulation after fetching from the database. Quote Link to comment https://forums.phpfreaks.com/topic/118570-solved-date-format/#findComment-610448 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.