CFLib.org – Common Function Library Project

MDYAsString(daytString)

Last updated November 01, 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);

}

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

Created by Raymond Camden / Design by Justin Johnson