When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
User Tip: Improving the Custom Date Formatting Function

From Al P.:

Just downloaded and used your custom DanDate() function, but it didn't have any way of illustrating an ordinal number. I've added this functionality to the function, and its below.

%O adds ordinal (th, nd, rd) to a number)

In DanDate() Function Add:
intPosItem = Instr(strFormat, "%O") Do While intPosItem > 0 strFormat = Left(strFormat, intPosItem-1) & Ordinal(DatePart("d",strDate)) & _ Right(strFormat, Len(strFormat) - (intPosItem + 1)) intPosItem = Instr(strFormat, "%O") Loop

Also need to add this:
Function Ordinal(aNum) ord = "th" if aNum = 1 or aNum = 21 then ord = "st" elseif aNum = 2 or aNum = 3 or aNum = 22 or aNum = 23 then ord = "nd" end if Ordinal = ord End Function

Anyway, use it, don't use it. Its up to you. :-)

ASP.NET [1.x] [2.0] | ASPFAQs.com | Advertise | Feedback | Author an Article