Have an account? Sign in
Login  Register  Facebook
How to archive data by month?
Hi Guys,

I have a problem regarding of archiving. How we are going to archives data by month?
I have 4 fields(id, dates, title,description). I want to archives my data by month in which you can see the Month automatically from database MySQL.

Example

Dates automatically display from database

News for November
News for October
News for September

when you click each of this month it will directly open a page archives for each month.

Can anyone help me please. I really confuse how to do it. Thanks for advance guys.
Started: September 22, 2011 Latest Activity: September 22, 2011 phparchives
2 Answers
Is this correct?
SELECT 
  date_format(dates, '%Y-%M') as monthly_display
FROM 
  your_table
GROUP BY 
  date_format(dates, '%Y-%M');


And is the output of this SELECT * FROM table_name WHERE MONTH(date_column) = 4 ?

Posted: roly
In: September 22, 2011

use date_format
SELECT 
  date_format(your_column, '%Y-%M') as monthly_display
FROM 
  your_table
GROUP BY 
  date_format(your_column, '%Y-%M');
or you can do by this
SELECT * FROM table_name WHERE MONTH(date_column) = 4
for april month

Posted: MacOS
In: September 22, 2011

Your Answer

xDo you want to answer this question? Please login or create an account to post your answer