469,610 Members | 1,494 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,610 developers. It's quick & easy.

Startdate - Enddate dropdown not working ASP, IIS6

I have a startdate-enddate dropdown in asp that works great on my
development machine (XP Pro IIS5) but when I port it over to the web
server (Win Server 2003, IIS6), I do not get the desired results. What
should happen is that the start-end range should show the current
week. Instead, the start-end range defaults to 2 months earlier, when
the page was deployed.

I have added some code below:

<% dim begindate, enddate, startdate %>
<form method="post">
<input name="employee_id" type="hidden" value="<%=
trim(request("employee_id")) %>">
<input name="office_id" type="hidden" value="<%=
trim(request("office_id")) %>">
<select name="weekbegin" onChange="submit()">
<%
startdate = formatDateTime(dateAdd("d", 2 - weekday(now), now),
vbShortDate)
for x = 0 to 365 step 7
begindate = formatDateTime(dateAdd("d", 2 - weekday(now) + x, now),
vbShortDate)
enddate = dateAdd("d", 6, begindate)

if begindate = request("weekbegin") then
%>
<option value="<%= begindate %>" selected><%= begindate & " to " &
enddate %></option>
<%
else
%>
<option value="<%= begindate %>"><%= begindate & " to " & enddate %></
option>
<%
end if
next
%>
</select>
</form>

Any help or insight would be appreciated.

Thanks

Oct 3 '07 #1
2 1972
sd_eds wrote on 03 okt 2007 in microsoft.public.inetserver.asp.general:
I have a startdate-enddate dropdown in asp that works great on my
development machine (XP Pro IIS5) but when I port it over to the web
server (Win Server 2003, IIS6), I do not get the desired results. What
should happen is that the start-end range should show the current
week. Instead, the start-end range defaults to 2 months earlier, when
the page was deployed.

I have added some code below:

<% dim begindate, enddate, startdate %>
Not necessary, unless you use
Option Explicit
first
<form method="post">
<input name="employee_id" type="hidden" value="<%=
trim(request("employee_id")) %>">
<input name="office_id" type="hidden" value="<%=
trim(request("office_id")) %>">
<select name="weekbegin" onChange="submit()">
submit() needs a form object:

onChange="this.form.submit()"
<%
startdate = formatDateTime(dateAdd("d", 2 - weekday(now), now),
vbShortDate)
the weekday() 0 day is system dependent!

use:

Weekday(now, 1)

for x = 0 to 365 step 7
begindate = formatDateTime(dateAdd("d", 2 - weekday(now) + x, now),
vbShortDate)
for x = 2 - weekday(now) to 2 - weekday(now) + 365 step 7
theBegindate = dateAdd("d", x, now)
[see below]
enddate = dateAdd("d", 6, begindate)
You are not dateAdd to a date variable, but to a date string!!!

The date string is system dependent!

try this:

theStartdate = dateAdd("d", 2 - weekday(now), now)
startdate = formatDateTime(theStartdate ,2)

vbShortDate is not defined in vbscript, use number 2

theBegindate = dateAdd("d", 2 - weekday(now) + x, now)
begindate = formatDateTime(theBegindate ,2)

theEnddate = dateAdd("d", 6, theBegindate )
enddate = formatDateTime(theEnddate ,2)
if begindate = request("weekbegin") then
Never use a general request, do a safer request.form()

%>
<option value="<%= begindate %>" selected><%= begindate & " to " &
enddate %></option>
<%
else
%>
<option value="<%= begindate %>"><%= begindate & " to " & enddate %></
option>
<%
end if
next
%>
</select>
</form>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Oct 3 '07 #2
Thanks for the help.

Oct 3 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.