Getting Weekday names by using WeekDay and WeekDayName functions in ASPFrom a date variable or from a date we can get the weekday number staring from Sunday as 1 and Saturday as 7 ( see the table at the end ) by using weekday() function. Here is the syntax of weekday function.
Here we have taken one date but we can also use any date variable as input to the WeekDay function. Like this …
Here d_mydate is a date variable and we can assign any date value to it.
The output of this function will be between 1 and 7 depending on the weekday of the input value. The example
The output of above line is 3. It represents Tuesday of the week. To get directly the name of the weekday we can use WeekDayName() function. This function takes the number of weekday and returns the name of the weekday. Here is the syntax of WeekDayName() function.
Here weekday_number is the variable holding the weekday number, type is an optional Boolean argument to specify long or short name of the weekday to be returned. False value of type returns Long name and True value returns short name. By default it is set to False. Here are some examples of WeekDayName function.
This will give output Wednesday
This will give output Wed
This will give output Thursday
Now let us try to print the name of the weekday from a date variable or date by using both WeekDay() and WeekDayName() function. Here is the code.
This will print long name of the weekday of today.
Table for WeekDays function values
This article is written by plus2net.com team.
Be the first to post comment on this article :