Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Returning Day as String

Avatar

Former Community Member
Does anyone know of a simple way to return the day of the month as a string? In my form, I need the date field split to return the system date as day of the month, the month and the year. I.e. On this fifth day of February, 2008.



I can get it to give me everything except the day as string. Unlike with month, DDD returns a null value.
4 Replies

Avatar

Former Community Member
i've had some success with this script:



> var oDate = new Date();

> var nDate = oDate.getDate();

> var aNumString = new Array("", "first", "second", "third");



> TextField.rawValue = aNumString[nDate];



you'll have to add string values to the aNumString array to account for all possible dates in a month, i.e. fourth for 4, thirtieth for 30, thirty-first for 31. it's a little tedious but i also haven't found a simple way of doing this, either...



~AJ~

Avatar

Former Community Member
Ariel,



Thanks for the help. It was just as I feared. ; )



Laura

Avatar

Level 6
I don't think I understand the question. To get the current system day of the month:



function getSystemDayOfMonth() {

var oToday = new Date();

return "" + oToday.getDate();

}

Avatar

Former Community Member
jared, your function works great but it returns a numeric value, i.e. 2/11/08 would return the '11' in your function. i haven't seen any javascript methods that would return a spelled-out value for the date, i.e. 'eleventh', which i think is what laura is after...