You are here: Re: Displaying records from current month only « All PHP « IT news, forums, messages
Re: Displaying records from current month only

Posted by Ehsan on 04/03/06 20:45

Hi,

Sorry for the late response. Am very ill so could not respond earlier.

If you want to go back 30 days or so, then you can try this:

SELECT id, date_format(date, '%D %M %Y') as date, title, article,
catagory, publication
FROM articles
WHERE date > SUBDATE(NOW(), 31)
ORDER BY `date` DESC

This query is quite similar to one that you used with some small
changes. I used SUBDATE instead of DATE_ADD because if you pass
2006-04-03 12:11:11 to DATE_ADD with interval of 31 days then return
will be 2006-05-03 12:11:11. SUBDATE goes 31 days (or number of days
you specify) BACK. Now above query is searching for records with date
being greater than the returned value from SUBDATE(NOW(), 31). You dont
need to specify any condition to match year in this case as it is
already doing it. Taking time duration between current date to past 31
days.

SUBDATE(NOW(), 31) is giving you a date-time duration from current
date-time to exactly 31 days back. You can use it.

I have recently developed a blog for my own site. I will be publishing
it with the new interface design very soon. There for default view I
used normal query with pagination, i.e. Limit 1, 10 or Limit 11, 20.
Sorting the result by post date time in DESCENDING order. That means
latest entry shows up first and keeps going. I do have one shortcut
list for monthly blog list as well. In that list I have shown list of
the months which has posts only. Example, March'06 had 2 posts so it
shows March 2006 - 2, and if January did not have any then it is not
shown in the list. You can use this style as well. Let me know if the
above solution served your purpose.

Thanks

Ehsan
http://ehsan.bdwebwork.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация