vikrantmohite Posted February 11, 2012 Share Posted February 11, 2012 Hi guys, I have stored some records in my table where table contains a column timestamp where I am storing a timestamp. I want to extract records for particular month with this timestamp. How I can write query for it?? Quote Link to comment https://forums.phpfreaks.com/topic/256883-extraction-help-in-mysql/ Share on other sites More sharing options...
joel24 Posted February 11, 2012 Share Posted February 11, 2012 SELECT * FROM table WHERE MONTH(FROM_UNIXTIME(timeStampField)) = 4 SELECT MONTH(FROM_UNIXTIME(timeStampField)) FROM table Quote Link to comment https://forums.phpfreaks.com/topic/256883-extraction-help-in-mysql/#findComment-1316947 Share on other sites More sharing options...
jcbones Posted February 11, 2012 Share Posted February 11, 2012 MySQL's timestamp is formatted YYYY-mm-dd H:I:S. You would not need to convert from UNIX_TIMESTAMP to get the month. Just use the MONTH() function. Quote Link to comment https://forums.phpfreaks.com/topic/256883-extraction-help-in-mysql/#findComment-1317102 Share on other sites More sharing options...
joel24 Posted February 12, 2012 Share Posted February 12, 2012 MySQL's timestamp is formatted YYYY-mm-dd H:I:S. You would not need to convert from UNIX_TIMESTAMP to get the month. Just use the MONTH() function. my bad, as soon as I saw timestamp I was thinking unix timestamp... brain fart Quote Link to comment https://forums.phpfreaks.com/topic/256883-extraction-help-in-mysql/#findComment-1317130 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.