Sideway BICK BlogSideway BICK BLOG from Sideway

A Sideway to Sideway Home

Link:http://output.to/sideway/default.asp?qno=180300026

Script, Scripting Language, VBScript elements, Server-Side VBScript Function MonthName, WeekdayName Function

VBScript Date/Time Functions

Functions for manipulating date or time expression.

MonthName Function

last updated 9/20/2017

Create a String from a given month expression by taking the given month expression as the numeric designation of the month between 1 and 12 inclusive, and with value representing the corresponding month of a year according to the specified abbreviate setting.

Syntax

MonthName(month[, abbreviate])

Argument

monthRequired. Any valid numeric expression, which is equal to Round(month), with value between 1 and 12 inclusive as the numeric designation of the month of a year.abbreviateOptional setting. Boolean value that is used to indicate if the returned month name is to be abbreviated. If abbreviate setting is omitted, false or 0 is used which means that the returned month name is not abbreviated.

Settings

abbreviate setting:

abbreviateDescription1, Truereturned month name is abbreviated.0, False (default)returned month name is not abbreviated.

Returns

Returns a Variant of String data subtype containing the String obtained from a given month expression by taking the given month expression as the numeric designation of the month between 1 and 12 inclusive, and with value representing the corresponding month of a year according to the specified abbreviate setting.

Returns of function:

monthMonthName(month), MonthName(month,0)MonthName(month,1)1JanuaryJan2FebruaryFeb3MarchMar4AprilApr5MayMay6JuneJun7JulyJul8AugustAug9SeptemberSep10OctoberOct11NovemberNov12DecemberDec

Special returns of function:

monthreturn valueNullRun-time ErrorEmptyRun-time Error""Run-time Error

Remarks

  • MonthName function is used to convert the numeric designation of the year between 1 and 12 inclusive to the corresponding month name according to the abbreviated setting.
  • The given month can be any numeric expression, which is equal to Round(month), with value between 1 and 12 inclusive.
  • For any other values, MonthName function returns Run-time error.

Requirement

2

Examples

Examples of MonthName function

ASP VbScript Command:
<script runat="server" language="VBScript">
Dim vars,mth,k,cmda,var:var=0
cmda=array("mth","MonthName(mth)","MonthName(mth,0)","MonthName(mth,1)")
Dim ucnt,tmp,i:ucnt=UBound(cmda):If var=1 Then:tmp="":Else:tmp="<b>vars</b>":End If:For i=0 to ucnt:tmp=tmp&"<b>"&rmv_ctrl(cmda(i))&", TypeName</b>":Next:Response.Write "Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp<br />"&"<i>"&tmp&"</i>"
Function dsp_x:Dim tmp_a,tmp_b,i:If varx=0  Then:Execute vars:End If:If var=1 Then:tmp_a="":Else:tmp_a=rmv_ctrl(vars):End If:For i=0 to ucnt:tmp_b=cmd_b(cmda(i)):if i/2=fix(i/2) Then:tmp_b="<b>"&tmp_b&"</b>":End If:tmp_a=tmp_a&tmp_b:Next:Response.Write "<i>"&tmp_a&"</i>":End Function
Function rmv_ctrl(blk_str):Select Case blk_str:Case chr(0):blk_str="NUL":Case chr(1):blk_str="SOH":Case chr(2):blk_str="STX":Case chr(3):blk_str="ETX":Case chr(4):blk_str="EOT":Case chr(5):blk_str="ENQ":Case chr(6):blk_str="ACK":Case chr(7):blk_str="BEL":Case chr(8):blk_str="BS":Case chr(9):blk_str="HT":Case chr(10):blk_str="LF":Case chr(11):blk_str="VT":Case chr(12):blk_str="FF":Case chr(13):blk_str="CR":Case chr(14):blk_str="SO":Case chr(15):blk_str="SI":Case chr(16):blk_str="DLE":Case chr(17):blk_str="DC1":Case chr(18):blk_str="DC2":Case chr(19):blk_str="DC3":Case chr(20):blk_str="DC4":Case chr(21):blk_str="NAK":Case chr(22):blk_str="SYN":Case chr(23):blk_str="ETB":Case chr(24):blk_str="CAN":Case chr(25):blk_str="EM":Case chr(26):blk_str="SUB":Case chr(27):blk_str="ESC":Case chr(28):blk_str="FS":Case chr(29):blk_str="GS":Case chr(30):blk_str="RS":Case chr(31):blk_str="US":Case chr(127):blk_str="DEL":End Select:rmv_ctrl=blk_str:If IsNull(blk_str) OR IsEmpty(Blk_str) OR blk_str="" OR IsNumeric(Blk_str) Then:Else:rmv_ctrl=Replace(Replace(Replace(Replace(Replace(blk_str,"&","&amp;"),"  "," &nbsp;"),"""","&quot;"),"<","&lt;"),">","&gt;"): End If :End Function
Function cmd_b(blk_str):cmd_b="["&cmd_x(blk_str)&"], "&cmd_x("TypeName("&blk_str&")"):End Function
Function cmd_x(blk_str):On Error Resume Next:Dim xans, tmp:xans="":tmp="":execute "xans="&blk_str:If Err.Number <> 0  Then:xans=cmd_x("TypeName("&blk_str&")"):Select Case xans:Case 9::Case Else:xans="error":End Select:End If:If IsArray(xans)=False Then:cmd_x=rmv_ctrl(xans): Else:tmp=lst_arry(xans):cmd_x=trim(tmp):End If:End Function
Function lst_arry(blk_str):Dim tmp,i,q:q="""":tmp="":For i=0 to UBound(blk_str):if VarType(blk_str(i))>1 And VarType(blk_str(i))<6 Then:q="'":End If:tmp=tmp&" "&q&rmv_ctrl(blk_str(i))&q:Next:lst_arry=trim(tmp):End Function

vars="mth=""1.4""":dsp_x
vars="mth=2.6":dsp_x
vars="mth=2.5":dsp_x
vars="mth=2.4":dsp_x
vars="mth=1.6":dsp_x
vars="mth=1.5":dsp_x
vars="mth=1.4":dsp_x
For k=1 to 12
vars="mth="&k:dsp_x
Next
</script>
HTML Web Page In-line Output:
Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp
varsmth, TypeNameMonthName(mth), TypeNameMonthName(mth,0), TypeNameMonthName(mth,1), TypeNamemth="1.4"[1.4], String[January], String[January], String[Jan], Stringmth=2.6[2.6], Double[March], String[March], String[Mar], Stringmth=2.5[2.5], Double[February], String[February], String[Feb], Stringmth=2.4[2.4], Double[February], String[February], String[Feb], Stringmth=1.6[1.6], Double[February], String[February], String[Feb], Stringmth=1.5[1.5], Double[February], String[February], String[Feb], Stringmth=1.4[1.4], Double[January], String[January], String[Jan], Stringmth=1[1], Integer[January], String[January], String[Jan], Stringmth=2[2], Integer[February], String[February], String[Feb], Stringmth=3[3], Integer[March], String[March], String[Mar], Stringmth=4[4], Integer[April], String[April], String[Apr], Stringmth=5[5], Integer[May], String[May], String[May], Stringmth=6[6], Integer[June], String[June], String[Jun], Stringmth=7[7], Integer[July], String[July], String[Jul], Stringmth=8[8], Integer[August], String[August], String[Aug], Stringmth=9[9], Integer[September], String[September], String[Sep], Stringmth=10[10], Integer[October], String[October], String[Oct], Stringmth=11[11], Integer[November], String[November], String[Nov], Stringmth=12[12], Integer[December], String[December], String[Dec], String

WeekdayName Function

last updated 9/21/2017

Create a String from a given weekday expression by taking the given weekday expression as the numeric designation of the week between 1 and 7 inclusive based on the specified firstdayofweek setting, and with value representing the corresponding weekday of a week according to the specified abbreviate setting.

Syntax

WeekdayName(weekday[, abbreviate[, firstdayofweek]])

Argument

weekdayRequired. The numeric designation for the day of the week. Numeric value of each day depends on setting of the firstdayofweek setting.abbreviateOptional. Boolean value that indicates if the weekday name is to be abbreviated. If omitted, the default is False, which means that the weekday name is not abbreviated.firstdayofweekOptional. Numeric value indicating the first day of the week. See Settings section for values.

Settings

abbreviate argument:

abbreviateDescription1, Truereturned month name is abbreviated.0, False (default)returned month name is not abbreviated.

firstdayofweek argument

vbConstantValueDescriptionvbUseSystemDayOfWeek0Use National Language Support (NLS) API setting.vbSunday1(default)Sunday .vbMonday2Monday.vbTuesday3Tuesday.vbWednesday4Wednesday.vbThursday5Thursday.vbFriday6Friday.vbSaturday7Saturday.

Returns

Returns a Variant of String data subtype containing the String obtained from a given weekday expression by taking the given weekday expression as the numeric designation of the week between 1 and 7 inclusive based on the specified firstdayofweek setting, and with value representing the corresponding weekday of a week according to the specified abbreviate setting.

Returns of function:

Default Weekday= weekday+ firstdayofweek-1WeekdayName(weekday), WeekdayName(weekday,0)WeekdayName(weekday,1)1SundaySun2MondayMon3TuesdayTue4WednesdayWed5ThursdayThu6FridayFri7SaturdaySat

Special returns of function:

monthreturn valueNullRun-time ErrorEmptyRun-time Error""Run-time Error

Remarks

  • WeekdayName function is used to convert the numeric designation of the weekday between 1 and 7 inclusive to the corresponding weekday name based on the firstdayofweek setting according to the abbreviated setting.
  • The given weekday can be any numeric expression, which is equal to Round(weekday), with value between 1 and 7 inclusive.
  • The weekday number cannot be convected to weekday name directly because the firstdayofweek setting will affect the relationship between the sequence of weekday number and the sequence of weekday name.
  • For any other values, WeekdayName function returns Run-time error.

Requirement

2

Examples

Examples of functions

ASP VbScript Command:
<script runat="server" language="VBScript">
Dim vars,wkd,abb,fdw,k,z,cmda,var:var=0
cmda=array("wkd","WeekdayName(wkd)","WeekdayName(wkd,abb)","WeekdayName(wkd,abb,1)","WeekdayName(wkd,abb,2)","WeekdayName(wkd,abb,3)","WeekdayName(wkd,abb,4)","WeekdayName(wkd,abb,5)","WeekdayName(wkd,abb,6)","WeekdayName(wkd,abb,7)")
Dim ucnt,tmp,i:ucnt=UBound(cmda):If var=1 Then:tmp="":Else:tmp="<b>vars</b>":End If:For i=0 to ucnt:tmp=tmp&"<b>"&rmv_ctrl(cmda(i))&", TypeName</b>":Next:Response.Write "Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp<br />"&"<i>"&tmp&"</i>"
Function dsp_x:Dim tmp_a,tmp_b,i:If varx=0  Then:Execute vars:End If:If var=1 Then:tmp_a="":Else:tmp_a=rmv_ctrl(vars):End If:For i=0 to ucnt:tmp_b=cmd_b(cmda(i)):if i/2=fix(i/2) Then:tmp_b="<b>"&tmp_b&"</b>":End If:tmp_a=tmp_a&tmp_b:Next:Response.Write "<i>"&tmp_a&"</i>":End Function
Function rmv_ctrl(blk_str):Select Case blk_str:Case chr(0):blk_str="NUL":Case chr(1):blk_str="SOH":Case chr(2):blk_str="STX":Case chr(3):blk_str="ETX":Case chr(4):blk_str="EOT":Case chr(5):blk_str="ENQ":Case chr(6):blk_str="ACK":Case chr(7):blk_str="BEL":Case chr(8):blk_str="BS":Case chr(9):blk_str="HT":Case chr(10):blk_str="LF":Case chr(11):blk_str="VT":Case chr(12):blk_str="FF":Case chr(13):blk_str="CR":Case chr(14):blk_str="SO":Case chr(15):blk_str="SI":Case chr(16):blk_str="DLE":Case chr(17):blk_str="DC1":Case chr(18):blk_str="DC2":Case chr(19):blk_str="DC3":Case chr(20):blk_str="DC4":Case chr(21):blk_str="NAK":Case chr(22):blk_str="SYN":Case chr(23):blk_str="ETB":Case chr(24):blk_str="CAN":Case chr(25):blk_str="EM":Case chr(26):blk_str="SUB":Case chr(27):blk_str="ESC":Case chr(28):blk_str="FS":Case chr(29):blk_str="GS":Case chr(30):blk_str="RS":Case chr(31):blk_str="US":Case chr(127):blk_str="DEL":End Select:rmv_ctrl=blk_str:If IsNull(blk_str) OR IsEmpty(Blk_str) OR blk_str="" OR IsNumeric(Blk_str) Then:Else:rmv_ctrl=Replace(Replace(Replace(Replace(Replace(blk_str,"&","&amp;"),"  "," &nbsp;"),"""","&quot;"),"<","&lt;"),">","&gt;"): End If :End Function
Function cmd_b(blk_str):cmd_b="["&cmd_x(blk_str)&"], "&cmd_x("TypeName("&blk_str&")"):End Function
Function cmd_x(blk_str):On Error Resume Next:Dim xans, tmp:xans="":tmp="":execute "xans="&blk_str:If Err.Number <> 0  Then:xans=cmd_x("TypeName("&blk_str&")"):Select Case xans:Case 9::Case Else:xans="error":End Select:End If:If IsArray(xans)=False Then:cmd_x=rmv_ctrl(xans): Else:tmp=lst_arry(xans):cmd_x=trim(tmp):End If:End Function
Function lst_arry(blk_str):Dim tmp,i,q:q="""":tmp="":For i=0 to UBound(blk_str):if VarType(blk_str(i))>1 And VarType(blk_str(i))<6 Then:q="'":End If:tmp=tmp&" "&q&rmv_ctrl(blk_str(i))&q:Next:lst_arry=trim(tmp):End Function

For k=1 to 3 step 0.5:vars="wkd="""&k&""":abb=Empty":dsp_x:Next:
For z=0 to 1:For k=1 to 7 :vars="wkd="&k&":abb="&z&"":dsp_x:Next:Next
</script>
HTML Web Page In-line Output:
Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp
varswkd, TypeNameWeekdayName(wkd), TypeNameWeekdayName(wkd,abb), TypeNameWeekdayName(wkd,abb,1), TypeNameWeekdayName(wkd,abb,2), TypeNameWeekdayName(wkd,abb,3), TypeNameWeekdayName(wkd,abb,4), TypeNameWeekdayName(wkd,abb,5), TypeNameWeekdayName(wkd,abb,6), TypeNameWeekdayName(wkd,abb,7), TypeNamewkd="1":abb=Empty[1], String[Sunday], String[Sunday], String[Sunday], String[Monday], String[Tuesday], String[Wednesday], String[Thursday], String[Friday], String[Saturday], Stringwkd="1.5":abb=Empty[1.5], String[Monday], String[Monday], String[Monday], String[Tuesday], String[Wednesday], String[Thursday], String[Friday], String[Saturday], String[Sunday], Stringwkd="2":abb=Empty[2], String[Monday], String[Monday], String[Monday], String[Tuesday], String[Wednesday], String[Thursday], String[Friday], String[Saturday], String[Sunday], Stringwkd="2.5":abb=Empty[2.5], String[Monday], String[Monday], String[Monday], String[Tuesday], String[Wednesday], String[Thursday], String[Friday], String[Saturday], String[Sunday], Stringwkd="3":abb=Empty[3], String[Tuesday], String[Tuesday], String[Tuesday], String[Wednesday], String[Thursday], String[Friday], String[Saturday], String[Sunday], String[Monday], Stringwkd=1:abb=0[1], Integer[Sunday], String[Sunday], String[Sunday], String[Monday], String[Tuesday], String[Wednesday], String[Thursday], String[Friday], String[Saturday], Stringwkd=2:abb=0[2], Integer[Monday], String[Monday], String[Monday], String[Tuesday], String[Wednesday], String[Thursday], String[Friday], String[Saturday], String[Sunday], Stringwkd=3:abb=0[3], Integer[Tuesday], String[Tuesday], String[Tuesday], String[Wednesday], String[Thursday], String[Friday], String[Saturday], String[Sunday], String[Monday], Stringwkd=4:abb=0[4], Integer[Wednesday], String[Wednesday], String[Wednesday], String[Thursday], String[Friday], String[Saturday], String[Sunday], String[Monday], String[Tuesday], Stringwkd=5:abb=0[5], Integer[Thursday], String[Thursday], String[Thursday], String[Friday], String[Saturday], String[Sunday], String[Monday], String[Tuesday], String[Wednesday], Stringwkd=6:abb=0[6], Integer[Friday], String[Friday], String[Friday], String[Saturday], String[Sunday], String[Monday], String[Tuesday], String[Wednesday], String[Thursday], Stringwkd=7:abb=0[7], Integer[Saturday], String[Saturday], String[Saturday], String[Sunday], String[Monday], String[Tuesday], String[Wednesday], String[Thursday], String[Friday], Stringwkd=1:abb=1[1], Integer[Sunday], String[Sun], String[Sun], String[Mon], String[Tue], String[Wed], String[Thu], String[Fri], String[Sat], Stringwkd=2:abb=1[2], Integer[Monday], String[Mon], String[Mon], String[Tue], String[Wed], String[Thu], String[Fri], String[Sat], String[Sun], Stringwkd=3:abb=1[3], Integer[Tuesday], String[Tue], String[Tue], String[Wed], String[Thu], String[Fri], String[Sat], String[Sun], String[Mon], Stringwkd=4:abb=1[4], Integer[Wednesday], String[Wed], String[Wed], String[Thu], String[Fri], String[Sat], String[Sun], String[Mon], String[Tue], Stringwkd=5:abb=1[5], Integer[Thursday], String[Thu], String[Thu], String[Fri], String[Sat], String[Sun], String[Mon], String[Tue], String[Wed], Stringwkd=6:abb=1[6], Integer[Friday], String[Fri], String[Fri], String[Sat], String[Sun], String[Mon], String[Tue], String[Wed], String[Thu], Stringwkd=7:abb=1[7], Integer[Saturday], String[Sat], String[Sat], String[Sun], String[Mon], String[Tue], String[Wed], String[Thu], String[Fri], String

Sideway BICK Blog

26/03


Copyright © 2000-2020 Sideway . All rights reserved Disclaimerslast modified on 26 January 2013