Gossamer Forum
Home : Products : DBMan : Installation :

Changing date variable in SSI to allow dbman to show recds from past 2 days - how?

Quote Reply
Changing date variable in SSI to allow dbman to show recds from past 2 days - how?
I want my website (LabourStart - http://www.labourstart.org) to show only records where the date is from today or yesterday, which are then sorted on another field (country).

This can be done easily enough in dbman's search, but how do I hard-code this in the SSI include which calls the script? My problem is that I cannot figure out how to get SSI to deduct a value from the variable for date, which I'm calling $day.

In my index.shtml page, I begin with these lines, which assign today's day to this field:

<!--#config timefmt="%d-%b-%Y"-->
<!--#set var="DBMAN_DATE" value="${DATE_LOCAL}"-->
<!--#config timefmt="%d"-->
<!--#set var="day" value="${DATE_LOCAL}"-->

Then, for example, if today is the 3rd of the month, I ask it to show me records from the 2nd of the month and the 3rd, as follows:

<!--#if expr="$day = 3"-->
<!--#set var="day" value="1"-->
<!--#endif -->

I repeated this for every day of the month, from 1 to 31.

What I wanted to do was be able to tell the SSI that I wanted $day to equal $day-2. But I can't find out anywhere how to do this.

The script continues by assigning values to month and year, as follows:

<!--#config timefmt="%b"-->
<!--#set var="month" value="${DATE_LOCAL}"-->
<!--#config timefmt="%Y"-->
<!--#set var="year" value="${DATE_LOCAL}"-->

And then creates a new variable called DBMAN_DATE2 which includes the new date:

<!--#set var="DBMAN_DATE2" value="$day-$month-$year"-->

I then restore the default format for outputting dates, as follows:

<!--#config timefmt="%d-%b-%Y"-->

And finally, run the dbman script:

<!--#include virtual="/cgi-bin/dbman/db.cgi?db=default&Country=*&uid=default&mh=100&sb=3&so=ascend&view_records=View+Records&ssi=1&Priority=2&Date=>$D BMAN_DATE2" -->

As I said, this sort of works, but it's ridiculous to have to assign hard-coded values for every one of the 31 days in the month when you think there'd be a way to tell it that $day = $day-2.

Anyone have a suggestion of how to do this?

Thanks!

Eric

------------------
Quote Reply
Re: Changing date variable in SSI to allow dbman to show recds from past 2 days - how? In reply to
Hi

I think that you would be best off working in seconds - it's easy to deduct 48 hours of seconds from the current time in seconds.

I guess you would then need a bit of code in html.pl to convert the time in seconds back into the DBMan date format and serve up the records.

I'm not quite sure how to do this however...

Chris