Get ready for BLACK FRIDAY shopping starting in

Forums

This topic is locked

Date navigation with url

Posted 09 Apr 2002 23:59:55
1
has voted
09 Apr 2002 23:59:55 Erik Brabants posted:
I'm trying to pass a date in the string of the url. but this code doesn't seem to work.
I already tried to add "#" before and after the date in the url , but that doesn't help either.
Help ??

var Recordset2__MMColParam = "#10/10/2000#";
if(String(Request.Querystring("ALLEDATUM" ) != "undefined" {
Recordset2__MMColParam = String(Request.Querystring("ALLEDATUM" );

var Recordset2 = Server.CreateObject("ADODB.Recordset";
Recordset2.ActiveConnection = MM_VANKERKHOVEN_STRING;
Recordset2.Source = "SELECT * FROM OPZOEK WHERE ALLEDATUM <= "+ Recordset2__MMColParam.replace(/'/g, "''" + " AND FONDSID="+ Recordset2__MMColParam2.replace(/'/g, "''" + " ORDER BY ALLEDATUM DESC";
Recordset2.CursorType = 0;
Recordset2.CursorLocation = 2;
Recordset2.LockType = 3;
Recordset2.Open();
var Recordset2_numRows = 0;
%>

Replies

Replied 10 Apr 2002 19:24:46
10 Apr 2002 19:24:46 David Behan replied:
Here is a bit of code that gets todays date, splits it into day month year, checks for a leap year, finds out tomorrows date, and yesterdays date and puts them back together into a variable.

Modify as you need to and I'll help if you need any...

<%
'========================================'
' '
' Written by David Behan - 26 March 2002 '
' Any questions - email me at: '
' '
' '
' '
'You can use this script or modification '
'of it as long as you include this header'
' '
'=========================================



'=========================================
'Get todays date from the server clock and
'split it into day, month and year.
'=========================================

todaysday = day(now())
todaysmonth = month(now())
todaysyear = year(now())

'format the date with 0 in front of a single digit day
IF todaysday <10 THEN
todaysdaynew = "0" & todaysday
ELSE
todaysdaynew = todaysday
END IF

'format the date with 0 in front of a single digit month
IF todaysmonth <10 THEN
todaysmonthnew = "0" & todaysmonth
ELSE
todaysmonthnew = todaysmonth
END IF

'=========================================
'Find out how many days are in this month.
'This will also check whether it is a leap
'year and if so, give february 29 days.
'=========================================

IF todaysmonth = 1 OR todaysmonth = 3 OR todaysmonth = 5 OR todaysmonth = 7 OR todaysmonth = 8 OR todaysmonth = 10 OR todaysmonth = 12 THEN
daysintodaysmonth = 31
END IF

IF todaysmonth = 4 OR todaysmonth = 6 OR todaysmonth = 9 OR todaysmonth = 11 THEN
daysintodaysmonth = 30
END IF

IF todaysmonth = 2 THEN
'If todays year divide by 4 is a whole number then it is a leap year.
IF todaysyear MOD 4 = 0 THEN
daysintodaysmonth = 29
ELSE
daysintodaysmonth = 28
END IF
END IF

'=========================================
'Find out how many days were in last month
'=========================================

IF todaysmonth = 1 THEN
lastmonth = 12
ELSE
lastmonth = todaysmonth - 1
END IF

IF lastmonth = 1 OR lastmonth = 3 OR lastmonth = 5 OR lastmonth = 7 OR lastmonth = 8 OR lastmonth = 10 OR lastmonth = 12 THEN
daysinlastmonth = 31
END IF

IF lastmonth = 4 OR lastmonth = 6 OR lastmonth = 9 OR lastmonth = 11 THEN
daysinlastmonth = 30
END IF

IF lastmonth = 2 THEN
'If todays year divide by 4 is a whole number then it is a leap year.
IF todaysyear MOD 4 = 0 THEN
daysinlastmonth = 29
ELSE
daysinlastmonth = 28
END IF
END IF

'=========================================
'Now we have todays month lenght we need
'to find out what tomorrows date will be.
'=========================================

IF todaysday = daysintodaysmonth THEN
tomorrowsday = 1
IF todaysmonth = 12 THEN
tomorrowsmonth = 1
tomorrowsyear = todaysyear + 1
ELSE
tomorrowsmonth = todaysmonth + 1
tomorrowsyear = todaysyear
END IF
ELSE
tomorrowsday = todaysday + 1
tomorrowsmonth = todaysmonth
tomorrowsyear = todaysyear
END IF

'format the date with 0 in front of a single digit day
IF tomorrowsday <10 THEN
tomorrowsdaynew = "0" & tomorrowsday
ELSE
tomorrowsdaynew = tomorrowsday
END IF

'format the date with 0 in front of a single digit month
IF tomorrowsmonth <10 THEN
tomorrowsmonthnew = "0" & tomorrowsmonth
ELSE
tomorrowsmonthnew = tomorrowsmonth
END IF

'=========================================
'Now we have both today and tomorrows date
'we only need yeasterdays date.
'=========================================

IF todaysday = 1 THEN
yesterdaysday = daysinlastmonth
IF todaysmonth = 1 THEN
yesterdaysmonth = 12
yesterdaysyear = todaysyear - 1
ELSE
yesterdaysmonth = todaysmonth - 1
yesterdaysyear = todaysyear
END IF
ELSE
yesterdaysday = todaysday - 1
yesterdaysmonth = todaysmonth
yesterdaysyear = todaysyear
END IF

'format the date with 0 in front of a single digit day
IF yesterdaysday <10 THEN
yesterdaysdaynew = "0" & yesterdaysday
ELSE
yesterdaysdaynew = yesterdaysday
END IF

'format the date with 0 in front of a single digit month
IF yesterdaysmonth <10 THEN
yesterdaysmonthnew = "0" & yesterdaysmonth
ELSE
yesterdaysmonthnew = yesterdaysmonth
END IF

'====================================================
'The variables you know have to use are:
'
'yesterdaysdaynew, yesterdaysmonthnew, yesterdaysyear
'todaysdaynew, todaysmonthnew, todaysyear,
'tomorrowsdaynew, tomorrowsmonthnew, tomorrowsyear
'====================================================

'==============================================
'The next step will combine the variables back
'into a single date variable. This is being
'developed for Irish users so for the American
'format, you will need to swop the variables
'around. We will do this for today, tomorrow &
'yesterday.
'==============================================

todaysdate = todaysdaynew & "/" & todaysmonthnew & "/" & todaysyear
tomorrowsdate = tomorrowsdaynew & "/" & tomorrowsmonthnew & "/" & tomorrowsyear
yesterdaysdate = yesterdaysdaynew & "/" & yesterdaysmonthnew & "/" & yesterdaysyear


'=========================================
' END DATE FUNCTION
'=========================================

%>

_________________________
David Behan - www.bmor.com
Replied 10 Apr 2002 19:30:47
10 Apr 2002 19:30:47 David Behan replied:
With the script above, it makes the date into a text string and you can filter the database on that particular date or have an option to go to tomorrows info or yesterdays info. With a bit of manipulation of this code I was able to set it to work through the query string filter for todays date. Then if the user wanted to go through to tomorrow and the each day after they just clicked next day or previous day, etc.

Hope this helps a bit...

_________________________
David Behan - www.bmor.com

Reply to this topic