Dates with the Ordinal Suffix

Submitted by:Jhon Jhon

Date added:15 July, 2012

Category:ASP

This example has an ordinal suffix: Sunday 15th July

Tags: ordinal suffix

Code Snippet:

<%
'Declare variables
Dim curDayOftheWeek, curMonth, curDay
'Return the numeric day of the week Sunday = 1 etc
curDayOftheWeek=(weekday(date))
Select Case curDayOftheWeek
Case 1 Response.write("Sunday")
Case 2 Response.write("Monday")
Case 3 Response.write("Tuesday")
Case 4 Response.write("Wednesday")
Case 5 Response.write("Thursday")
Case 6 Response.write("Friday")
Case 7 Response.write("Saturday")
End select
'Write out the numeric day of the month
Response.Write(" "&day(date))
'Return the numeric day of the month and assign to variable curDay
curDay=day(date)
'Write out the ordinal suffix according to the numeric day of the day
Select Case curDay
Case 1,21,31 response.write("st")
Case 2,22 response.write("nd")
Case 3,23 response.write("rd")
Case else response.write("th")
End select
'add a space
response.write " "
'Return the numeric month of the year and assign to variable curMonth
'1=January, 2=February etc
curMonth=(month(date))
Select Case curMonth
Case 1 Response.write("January")
Case 2 Response.write("February")
Case 3 Response.write("March")
Case 4 Response.write("April")
Case 5 Response.write("May")
Case 6 Response.write("June")
Case 7 Response.write("July")
Case 8 Response.write("August")
Case 9 Response.write("September")
Case 10 Response.write("October")
Case 11 Response.write("November")
Case 12 Response.write("December")
End Select
%>
 
 

Comments