or
<cfloop from=1 to=8 index="x" >
<cfif dayofWeek(createDate(year(
<cfoutput>
#day(createDate(year(now()
</cfoutput>
</cfif>
</cfloop>
Main Topics
Browse All Topicshow do i determine the value in numeric form (i.e 1/2/3/etc.) of the first monday of the current month? is there a cold fusion date tag that will help do this?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi, here's a function that performs what you're looking for, just pass year, month, and day of week, it will return the first day of week in month..
rob_lorentz,
nice code! this function follows the same idea, not a copy just a different way of doing it ;o)
---------------------
<cfscript>
function GetFirstDay(YY,MM,DD){
Num='';
for (i=1;i LTE 8;i=i+1){
if (dayofweek(createdate(YY,M
Num = day(createdate(year(YY),mo
return Num;
break;
}
}
}
</cfscript>
<!--- function parameters
GetFirstDay(year,month,day
day of week is
1=Sun,2=Mon,3=Tue,4=Wed,5=
--->
<cfoutput>
First Monday is #GetFirstDay(2006,7,2)#
</cfoutput>
regards,
~trail
another way if you prefer can be done like this
<cfscript>
function GetFirstDay(YY,MM,DD){
Switch(DD){
case'Sun':{D=1;break;}case
case'Tue':{D=3;break;}case
case'Thu':{D=5;break;}case
case'Sat':{D=7;break;}
}
for (i=1;i LTE 8;i=i+1){
if (dayofweek(createdate(YY,M
Num = day(createdate(year(YY),mo
return Num;
break;
}
}
}
</cfscript>
<cfoutput>
First Monday is #GetFirstDay(year(now()),m
</cfoutput>
this way you can pass whatever year, month, and then just put the three letter day you want to find the first day of the month for in the example above it's 'Mon'. has to be in the quotes ;o)
the advantage of the function is cutting down on code, while the cfscript may seem longer at first, in the rest of your document all you have to do is use the GetFirstDay(year,month,"da
~trail
It can be done without a loop which would be faster
Here is quick and dirty:
<cfset firstOfMonth = DateFormat(createDate(year
<cfif DayOfWeek(firstOfMonth) EQ 2>
<cfset FirstMonday = firstOfMonth>
<cfelseif DayOfWeek(firstOfMonth) EQ 1>
<cfset FirstMonday = DateAdd("d", 1, firstOfMonth)>
<cfelse>
<cfset FirstMonday = DateAdd("d", 9 - DayOfWeek(firstOfMonth), firstOfMonth)>
</cfif>
It can actually be even less code using mod arithmetic
More effective (no loops) solution:
<!--- Set month and year --->
<cfset y=2005>
<cfset m=11>
<!--- Find first Monday --->
<cfset d=CreateDate(y, m, 1)>
<cfset n=9-DayOfWeek(d)>
<cfif n GT 6>
<cfset n=n-7>
</cfif>
<cfset monday=DateFormat(DateAdd(
<!--- Result --->
<cfoutput>#monday#</cfoutp
Yes your right!
I gues it could work width some modification.
Maybe another simple solution:
<cfset daylist = "2,1,7,6,5,4,3">
<cfoutput>#DateFormat(crea
INSDivision6 don't get me wrong, you got a great solution but I just try to see if there is another simpel solution.
Business Accounts
Answer for Membership
by: rob_lorentzPosted on 2005-06-22 at 13:42:32ID: 14279303
try this...
now()), month(now()), x)) eq 2> r(now()), month(now()), x))# is the first Monday
<cfloop from=1 to=8 index="x" >
<cfif dayofWeek(createDate(year(
<cfoutput>
#dateFormat(createDate(yea
</cfoutput>
</cfif>
</cfloop>