Dates with the Ordinal Suffix
Download the code
Notice this example has an ordinal suffix:
Sunday 7th September
Below is the code that will do this.
<%
Dim curDayOftheWeek, curMonth, curDay
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
Response.Write(" "&day(date))
curDay=day(date)
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
response.write " "
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
%>
Other date and time related tutorials:
Read more on the Date, Time and Now VBScript functions
Here's a code snippet to display the day and date (eg. Mon 25 December).
How to get the current month name
Display the dates and times
Time and Date based greetings
IsDate Function
The DateDiff DateAdd and DatePart Functions
If you have any code snippets to share with full credit given then send an email to Codesnippets - You'll receive full credit and a link back to your site.
Site developed by Michael Wall - Web Design Belfast N.Ireland.
Copyright © 2000-2008. All rights reserved.
|