CFLib.org – Common Function Library Project

MDYAsString(daytString)

Last updated November 1, 2002

author

Larry Juncker

Version: 1 | Requires: CF5 | Library: DateLib

Description:
Returns a supplied date in the format "The Twenty Second day of September, in the year One Thousand Nine Hundred and Eighty Six."

Return Values:
Returns a string.

Example:

<cfoutput>
<cfset DaytString = "9/02/1986">
#DaytString# - #MDYAsString(DaytString)#<br>
#DateFormat(DateAdd("D","10",DaytString),"MM/DD/YYYY")# - #MDYAsString(DateAdd("D","10",DaytString))#<br>
#DateFormat(DateAdd("D","20",DaytString),"MM/DD/YYYY")# - #MDYAsString(DateAdd("D","20",DaytString))#<br>
#DateFormat(DateAdd("D","30",DaytString),"MM/DD/YYYY")# - #MDYAsString(DateAdd("D","30",DaytString))#<br>
#DateFormat(DateAdd("D","40",DaytString),"MM/DD/YYYY")# - #MDYAsString(DateAdd("D","40",DaytString))#<br>
</cfoutput>

Parameters:

Name Description Required
daytString Date object to convert. Yes

Full UDF Source:

/**
 * Returns a date in long text format.
 * 
 * @param daytString 	 Date object to convert. (Required)
 * @return Returns a string. 
 * @author Larry Juncker (ljuncker@aljcompserv.com) 
 * @version 1, November 1, 2002 
 */
function MDYAsString(daytString) {
    var dayList="First,Second,Third,Fourth,Fifth,Sixth,Seventh,Eighth,Ninth,Tenth,Eleventh,Twelveth,Thirteenth,Fourteenth,Fifteenth,Sixteenth,Seventeenth,Eighteenth,Nineteenth,Twentieth,Twenty First,Twenty Second,Twenty Third,Twenty Fourth,Twenty Fifth,Twenty Sixth,Twenty Seventh,Twenty Eighth,Twenty Ninth,Thirtieth,Thirty First";
    var DayAsString = ListGetAt(dayList,Day(DaytString));
    var numTenList="Ten,Twenty,Thirty,Fourty,Fifty,Sixty,Seventy,Eighty,Ninety";
    var numList="One,Two,Three,Four,Five,Six,Seven,Eight,Nine,Ten,Eleven,Twelve,Thirteen,Fourteen,Fifteen,Sixteen,Seventeen,Eighteen,Nineteen";
    var y1=mid(Year(DaytString),1,1);
    var y2=mid(Year(DaytString),2,1);
    var y3=mid(Year(DaytString),3,1);
    var y4=mid(Year(DaytString),4,1);
    var y2Str = '';
    var y3Str = '';
		
    if(y2 gt 0) y2Str = ListGetAt(numList,y2) & " Hundred";
    if(y3 gt 0) y3Str = ListGetAt(numTenList,y3);
				
    return "The " & DayAsString & " day of " & MonthAsString(Month(DaytString)) & ", in the year " & ListGetAt(numList,y1) & " Thousand "   & y2Str & " " &  " and " & y3Str & " " & ListGetAt(numList,y4);

}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson