Skip to main content
Inspiring
June 21, 2006
Answered

DayofWeek varibles???

<cfset ydate = DateFormat(Now(), "mm/dd/yyyy")>

How do i access the day value of ydate????
This topic is closed to new replies. Start a new post to keep the conversation going.
elDonricoCorrect answer
Inspiring
June 21, 2006
well, ydate will output like 6/21/2006 depending on what sort of day value you want...
eg
#DateFormat(ydate, 'DDDD')# will give you Wednesday
#DateFormat(ydate, 'DDD')# will give you Wed
#DateFormat(ydate, 'DD')# will give you 09 (if today was the ninth)
#DateFormat(ydate, 'D')# will give you 21
#Day(ydate)# will give you 21
#Dayofweek(ydate)# will give you 4
but, if you are going to be using it in your document i would just set another variable.
<cfset ydateDay = DateFormat(Now(), "d")>

hth

6 replies

Inspiring
June 22, 2006
This is my cue to pipe up with "Livedocs is an invaluable resource if
you're just learning CF":

http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000555.htm

--
Adam
Translate
Inspiring
June 22, 2006
> <cfset ydateDay = DateFormat(Now(), "d")>

Or even:

<cfset ydateDay = day(Now())>

--
Adam
Translate
BKBK
Community Expert
Community Expert
June 22, 2006
For almost all, if not all, the list functions that take a delimiter as argument, the default delimiter is usually a comma. There is an understanding that, in such cases, one may leave out the delimiter argument.

Hence, with a comma as list-delimiter, two arguments are sufficient for ListGetAt().

<cfset ydate = DateFormat(Now(), "mm,dd,yyyy")>
<cfset dayValue = listGetAt(ydate,2)>
dayValue: <cfoutput>#dayValue#</cfoutput>

However, in your case, the list-delimiter "/" is not a comma, and so must be explicitly stated.

Translate
BKBK
Community Expert
Community Expert
June 22, 2006
<cfset ydate = DateFormat(Now(), "mm/dd/yyyy")>
<cfset dayValue = listGetAt(ydate,2,"/")>
dayValue: <cfoutput>#dayValue#</cfoutput>

Translate
Inspiring
June 22, 2006
that is another way to do it...


BKBK, i have the coldfusion mx book by macromedia and it doesnt mention anything about requiring delimiters for the ListGetAt() function... it just says ListGetAt(List, Position)... do you know why this is? is it really

ListGetAt(List, Position, "delimeter") ??
Translate
elDonricoCorrect answer
Inspiring
June 21, 2006
well, ydate will output like 6/21/2006 depending on what sort of day value you want...
eg
#DateFormat(ydate, 'DDDD')# will give you Wednesday
#DateFormat(ydate, 'DDD')# will give you Wed
#DateFormat(ydate, 'DD')# will give you 09 (if today was the ninth)
#DateFormat(ydate, 'D')# will give you 21
#Day(ydate)# will give you 21
#Dayofweek(ydate)# will give you 4
but, if you are going to be using it in your document i would just set another variable.
<cfset ydateDay = DateFormat(Now(), "d")>

hth

Translate