Gossamer Forum
Home : Products : DBMan : Installation :

Display records added last n days

Quote Reply
Display records added last n days
How can I display records added last n days?
Say I would like to add a "What's new" button
so that the users can display all new records added last 3 days.

Many thanks.
Quote Reply
Re: Display records added last n days In reply to
I would be interested in that as well. If you figure out how to do such a thing, please let me know. What about a "top 10" list like "cool" on links.


------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: Display records added last n days In reply to
Here's what I did.

In html.pl, I added the following lines at the beginning of sub html_home:
---------------------------
@DaysOfMonths = (31,28,31,30,31,30,31,31,30,31,30,31);
@MonthNames = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec' );
@time = localtime(time);
$TodayMonth = $time[4];
$TodayDay = $time[3];
$TodayYear = $time[5] + 1900;
$n = 7; #the number of days you want to include in your "What's New"
$LastDay = $TodayDay - $n;
if ( $LastDay > 0 ) { #day n was this month
$LastMonth = $TodayMonth;
$LastYear = $TodayYear;
}
else { #day n was last month
if ( $TodayMonth > 0 ) { #for all months except January
$LastMonth = $TodayMonth - 1;
$LastDay = $DaysOfMonths[$LastMonth] + $LastDay;
$LastYear = $TodayYear;
}
else { #for the month of January
$LastMonth = 11;
$LastDay = 31 + $LastDay;
$LastYear = $TodayYear - 1;
}
}
$Last = "$LastDay-$MonthNames[$LastMonth]-$LastYear"; # assuming the default date format

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

Then, wherever you want your "What's New," (in the same subroutine!) add a link like:

------------------
<a href="$db_script_link_url&date=%3E$Last&view_records=1"><$font><B>What's New</B></font></a>
------------------------

That, of course, assumes that your date field is called "date." Remember that case counts, so "date" is not the same as "Date" or "DATE." Also, I tried using date-gt=$Last, but it didn't work.

BTW, the above is not adjusted for leap years. I decided to wait until it was closer to the time to deal with it.

I have no idea about a "what's cool" feature.

Hope this helps.



------------------
JPD


[This message has been edited by JPDeni (edited December 18, 1998).]
Quote Reply
Re: Display records added last n days In reply to
I did a little tweaking on the "What's New" mod I posted here -- including adding leap year support. If you're interested in seeing the mod along with a demo, you can see it at

http://www.drizzle.com/~hall/dbmod/new.html



------------------
JPD
Quote Reply
Re: Display records added last n days In reply to
I added your new version of the what's new mod and I am getting a error stating that the date format is invalid even though it is the same one that I am using.

Any ideas? Thanks for the mod.



------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: Display records added last n days In reply to
Is it up on the web where I can see it? Sometimes that date formatting is really odd and can cause some problems where it doesn't seem they should be.

Did you change the formatting from the original? I didn't test it out to be sure it would work with all formats. I just assumed -- and we all know what trouble *that* can cause! :-)



------------------
JPD
Quote Reply
Re: Display records added last n days In reply to
Hi JPD

This address seems out of date:

http://www.drizzle.com/~hall/dbmod/new.html

have you got a address for it?

Chris
Quote Reply
Re: Display records added last n days In reply to
Wow! Messages from December!! Smile

You can see the entire list of mods I have available at
http://www.jpdeni.com/dbman/mods.html

The "What's New" mod is there, at the bottom of the list. It's a whole lot better than the one I had in December.


------------------
JPD