dateLetters(dateStr[, formatStr])
Last updated May 22, 2003
Version: 1 | Requires: CF5 | Library: DateLib
Description:
This will return a given date in a long formated string including the optional letters ie 1st,2nd,3rd,4th etc.
Return Values:
Returns a string.
Example:
<cfoutput>
#dateLetters(now())#
</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
dateStr | Date to use. | Yes |
formatStr | Format string for month and year. | No |
Full UDF Source:
/**
* Add's the st,nd,rd,th after a day of the month.
*
* @param dateStr Date to use. (Required)
* @param formatStr Format string for month and year. (Optional)
* @return Returns a string.
* @author Ian Winter (ian@defusionx.om)
* @version 1, May 22, 2003
*/
function dateLetters(dateStr) {
var letterList="st,nd,rd,th";
var domStr=DateFormat(dateStr,"d");
var domLetters='';
var formatStr = "";
if(arrayLen(arguments) gte 2) formatStr = dateFormat(dateStr,arguments[2]);
switch (domStr) {
case "1": case "21": case "31": domLetters=ListGetAt(letterList,'1'); break;
case "2": case "22": domLetters=ListGetAt(letterList,'2'); break;
case "3": case "23": domLetters=ListGetAt(letterList,'3'); break;
default: domLetters=ListGetAt(letterList,'4');
}
return domStr & domLetters & " " & formatStr;
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016