Print Page | Close Window

Seperating news items into months

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=11730
Printed Date: 31 March 2026 at 1:17am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Seperating news items into months
Posted By: WebDever
Subject: Seperating news items into months
Date Posted: 08 September 2004 at 5:44am

Hi there,

I've just finished building a simple news application foir my website, but I'd like to change the way the news items are displayed in the list.

What i'd like to do is seperate them into months, how the hell would I do this? I've got an idea, but not too sure, would it something like this:

  • Order them by date decending
  • find current month
  • loop for each month
    • loop for each news item in this current month
    • move forward a month

Thanks :)



-------------
--Ashley



Replies:
Posted By: dpyers
Date Posted: 08 September 2004 at 11:29am

The only thing I might add would be to only select items whose date was =/> current month and have the query do the sort - saves the 1st two steps. You'd also want the sort to be ascending - lowest date to highest.

Also would need to figure how to handle months (including current) with no news items - e.g. skip, display month header and a message, etc.

EDIT: One of the numerous Calendar/Event applications rhat display a month at a time will have code very similar to what you want to do.



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: ljamal
Date Posted: 08 September 2004 at 5:43pm
Begin by storing the current month and years to a variable. Compare year and month until you reach the month and year of your first record. Iterate through the record set only displaying the new month when the month for the record is different from the month stored in the variable. Update the variable with the montha nd year from the record set and continue unteil completed.




-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: WebDever
Date Posted: 09 September 2004 at 7:02am
Sorry to be cheeky, but could you write some example code to get me started please :)

-------------
--Ashley



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net