To read the article online, visit http://www.4GuysFromRolla.com/webtech/tips/t102599-3.shtml

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. :-)


Article Information
Article Title: User Tip: Improving the Custom Date Formatting Function
Article Author: Scott Mitchell
Article URL: http://www.4GuysFromRolla.com/webtech/tips/t102599-3.shtml


Copyright 2017 QuinStreet Inc. All Rights Reserved.
Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers