Comprehensive date processing functions

Source: Internet
Author: User

Date Processing functions

<Script language = JavaScript>
Function fnsubmit (strpage)
{
Document. Forms [0]. Action = strpage
Document. Forms [0]. Submit ()
}

</SCRIPT>
<%

Call writedropdowns

Sub writedropdowns ()
Dim strselflink
Strselflink = request. servervariables ("script_name ")
Response. Write "<form name = dates method = post>" & vbcrlf
Response. write monthdropdown ("month1", false, request ("month1"), strselflink) & "" & daydropdown ("day1", "", getdaysinmonth (Request ("month1 "), request ("year1"), request ("day1") & "& yeardropdown (" year1 "," "," ", request (" year1 "), strselflink) & vbcrlf
Response. Write "</form>" & vbcrlf
End sub

Function monthdropdown (strname, blnnum, strselected, strselflink)
Dim strtemp, I, strselectedstring
Strtemp = "<select name = '" & strname & "'onchange = 'javascript: fnsubmit (" & CHR (34) & strselflink & CHR (34 )&") '> "& vbcrlf
Strtemp = strtemp & "<option value = '" & 0 & "'>" & "month" & "</option>" & vbcrlf
For I = 1 to 12
If strselected = CSTR (I) then
Strselectedstring = "selected"
Else
Strselectedstring = ""
End if

If blnnum then
Strtemp = strtemp & "<option value = '" & I & "'" & strselectedstring & ">" & I & "</option>" & vbcrlf
Else
Strtemp = strtemp & "<option value = '" & I & "'" & strselectedstring & ">" & monthname (I) & "</option>" & vbcrlf
End if
Next
Strtemp = strtemp & "</SELECT>" & vbcrlf
Monthdropdown = strtemp
End Function

Function yeardropdown (strname, intstartyear, intendyear, strselected, strselflink)

Dim strtemp, I, strselectedstring

If intstartyear = "" then
Intstartyear = year (now ())
End if

If intendyear = "" then
Intendyear = year (now () + 9
End if

Strtemp = "<select name = '" & strname & "'onchange = 'javascript: fnsubmit (" & CHR (34) & strselflink & CHR (34 )&") '> "& vbcrlf
Strtemp = strtemp & "<option value = '" & 0 & "'>" & "year" & "</option>" & vbcrlf
For I = intstartyear to intendyear
If strselected = CSTR (I) then
Strselectedstring = "selected"
Else
Strselectedstring = ""
End if
Strtemp = strtemp & "<option value = '" & I & "'" & strselectedstring & ">" & I & "</option>" & vbcrlf
Next
Strtemp = strtemp & "</SELECT>" & vbcrlf
Yeardropdown = strtemp
End Function

Function daydropdown (strname, intstartday, intendday, strselected)
Dim strtemp, I, strselectedstring
If intstartday = "" then
Intstartday = 1
End if

If intendday = "" then
Intendday = getdaysinmonth (month (now (), Year (now ()))
End if

Strtemp = "<select name = '" & strname & "'>" & vbcrlf
Strtemp = strtemp & "<option value = '" & 0 & "'>" & "day" & "</option>" & vbcrlf
For I = intstartday to intendday
If strselected = CSTR (I) then
Strselectedstring = "selected"
Else
Strselectedstring = ""
End if
Strtemp = strtemp & "<option value = '" & I & "'" & strselectedstring & ">" & I & "</option>" & vbcrlf
Next
Strtemp = strtemp & "</SELECT>" & vbcrlf
Daydropdown = strtemp
End Function

Function getdaysinmonth (strmonth, stryear)
Dim strdays
Select case CINT (strmonth)
Case 1, 3, 5, 7, 8, 10, 12:
Strdays = 31
Case 4, 6, 9, 11:
Strdays = 30
Case 2:
If (CINT (stryear) mod 4 = 0 and CINT (stryear) mod 100 <> 0) or (CINT (stryear) mod 400 = 0) then
Strdays = 29
Else
Strdays = 28
End if
'Case else:
End select

Getdaysinmonth = strdays
End Function
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.