Copy [Q23565624-GeneralFunction
<!--#include file="Q23565624-GeneralFunctions.asp"-->
<% Dim dtNow, iLoop, sDisplay, sValue
Dim sMonthFrom, sDayFrom, sYearFrom, iMonthFrom, iDayFrom, iYearFrom
Dim sMonthTo, sDayTo, sYearTo, iMonthTo, iDayTo, iYearTo
dtNow = Now()
bIsPostback = (Request.Form("IsPostback") <> "")
If NOT bIsPostback Then
iMonthFrom = 1: iDayFrom = 1: iYearFrom = Year(dtNow)
iMonthTo = Month(dtNow): iDayTo = Day(dtNow): iYearTo = Year(dtNow)
Else
sMonthFrom = Request.Form("monthfrom")
sDayFrom = Request.Form("dayfrom")
sYearFrom = Request.Form("yearfrom")
sMonthTo = Request.Form("monthto")
sDayTo = Request.Form("dayto")
sYearTo = Request.Form("yearto")
iMonthFrom = 0: If IsPositiveInteger(sMonthFrom) Then iMonthFrom = CLng(sMonthFrom)
iDayFrom = 0: If IsPositiveInteger(sDayFrom) Then iDayFrom = CLng(sDayFrom)
iYearFrom = 0: If IsPositiveInteger(sYearFrom) Then iYearFrom = CLng(sYearFrom)
iMonthTo = 0: If IsPositiveInteger(sMonthFrom) Then iMonthTo = CLng(sMonthTo)
iDayTo = 0: If IsPositiveInteger(sDayFrom) Then iDayTo = CLng(sDayTo)
iYearTo = 0: If IsPositiveInteger(sYearFrom) Then iYearTo = CLng(sYearTo)
If (iMonthFrom < 1) OR (iMonthFrom > 12) OR (iDayFrom < 1) OR (iDayFrom > 31) OR (iYearFrom < Year(dtNow)) Then
Call Response.Write("One or more fields associated with your FROM date is invalid.<hr>" & vbNewLine)
ElseIf (iMonthTo < 1) OR (iMonthTo > 12) OR (iDayTo < 1) OR (iDayTo > 31) OR (iYearTo < Year(dtNow)) Then
Call Response.Write("One or more fields associated with your TO date is invalid.<hr>" & vbNewLine)
ElseIf NOT IsDate(DateSerial(iYearFrom, iMonthFrom, iDayFrom)) Then
Call Response.Write("Untrapped error -- FROM date could not be created.<hr>" & vbNewLine)
ElseIf NOT IsDate(DateSerial(iYearTo, iMonthTo, iDayTo)) Then
Call Response.Write("Untrapped error -- TO date could not be created.<hr>" & vbNewLine)
Else
Call Response.Write("FROM Date: [" & DateSerial(iYearFrom, iMonthFrom, iDayFrom) & "]<br>" & vbNewLine)
Call Response.Write("TO Date: [" & DateSerial(iYearTo, iMonthTo, iDayTo) & "]<hr>" & vbNewLine)
End If
End If
%>
<form id="date" name="date" method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
<input type="hidden" name="IsPostback" value="Yes">
Select by Date Range: FROM:
<label>Day
<select name="dayfrom" id="dayfrom">
<% For iLoop = 1 to 31
sValue = iLoop
sDisplay = iLoop
bSelected = False: If (iDayFrom = iLoop) Then bSelected = True %>
<option value="<%=sValue%>"<% if bSelected then %> selected="selected"<% end if %>><%=sDisplay%></option>
<% Next %>
</select>
</label>
<label>Month
<select name="monthfrom" id="monthfrom">
<% For iLoop = 1 to 12
sValue = iLoop: If (iLoop < 10) Then sValue = "0" & sValue
sDisplay = MonthName(iLoop)
bSelected = False: If (iMonthFrom = iLoop) Then bSelected = True %>
<option value="<%=sValue%>"<% if bSelected then %> selected="selected"<% end if %>><%=sDisplay%></option>
<% Next %>
</select>
</label>
<label>Year
<select name="yearfrom" id="yearfrom">
<% For iLoop = Year(dtNow) to Year(dtNow)+2
sValue = iLoop
sDisplay = iLoop
bSelected = False: If (iYearFrom = iLoop) Then bSelected = True %>
<option value="<%=sValue%>"<% if bSelected then %> selected="selected"<% end if %>><%=sDisplay%></option>
<% Next %>
</select>
</label>
TO: <label>Day
<select name="dayto" id="dayto">
<% For iLoop = 1 to 31
sValue = iLoop
sDisplay = iLoop
bSelected = False: If (iDayTo = iLoop) Then bSelected = True %>
<option value="<%=sValue%>"<% if bSelected then %> selected="selected"<% end if %>><%=sDisplay%></option>
<% Next %>
</select>
</label>
<label>Month
<select name="monthto" id="monthto">
<% For iLoop = 1 to 12
sValue = iLoop: If (iLoop < 10) Then sValue = "0" & sValue
sDisplay = MonthName(iLoop)
bSelected = False: If (iMonthTo = iLoop) Then bSelected = True %>
<option value="<%=sValue%>"<% if bSelected then %> selected="selected"<% end if %>><%=sDisplay%></option>
<% Next %>
</select>
</label>
<label>Year
<select name="yearto" id="yearto">
<% For iLoop = Year(dtNow) to Year(dtNow)+2
sValue = iLoop
sDisplay = iLoop
bSelected = False: If (iYearTo = iLoop) Then bSelected = True %>
<option value="<%=sValue%>"<% if bSelected then %> selected="selected"<% end if %>><%=sDisplay%></option>
<% Next %>
</select>
</label>
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
<p></p>
</form>
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110:
- Q23565624-GeneralFunctions.asp.txt
- 3 KB
Rename as ASP (remove TXT extension) prior to use.





by: brad2575Posted on 2008-07-15 at 04:50:54ID: 22005939
You would just do something like this:
")) & "/" trim(request.form("monthfr om")) & "/" trim(request.form("yearFro m"))
Dim DateTo
DateTo = trim(request.form("dayFrom
' then do the same thing for the to date.