Jump to content


Archive.. how?


2 replies to this topic

#1 Marxx

    Young Padawan

  • Members
  • Pip
  • 116 posts
  • Gender:Male
  • Location:Finland

Posted 29 August 2007 - 03:47 AM

Hi all..

can't figure this out.. How can I archive my written text from sql?

I have in my database text which I need to archive by month and/or year.. Just like all blog systems do.
Well, I guess that this explais it all? :rolleyes:


Thanks for all help..

#2 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 29 August 2007 - 06:26 AM

It's quite simple assuming you are using date/time in what I would say is the best way :rolleyes:

If you are using a DATETIME field you can do a query like this:

SELECT * FROM `table` WHERE DATE_FORMAT(timestamp, '%m') = 6

That will take the DATETIME field (called in this case timestamp) and format it into the month number (much like date() would do with a unix timestamp) so you then check it against the number of the month you want to select articles for. In this case, 6, June.

The theory for day/week/month/year is much the same. %d %U (or %u) %m %y

http://dev.mysql.com/doc/refman/5.0/en/dat...ion_date-format

#3 Marxx

    Young Padawan

  • Members
  • Pip
  • 116 posts
  • Gender:Male
  • Location:Finland

Posted 29 August 2007 - 11:43 AM

Brilliant .. That is quite simple! :rolleyes:

I'll try it from here and maybe I need more help, maybe not.. :laugh:

Thank you Matthew.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users