Skip to main content
Inspiring
February 13, 2008
Question

Getting date for a specific day

  • February 13, 2008
  • 3 replies
  • 396 views
I just can't seem to wrap my head around this one today.
I need to find the date for a specific day. For example, the first Friday in
November. I can't seem to work out that first Friday part.

--
Bryan Ashcraft (remove BRAIN to reply)
Web Application Developer
Wright Medical Technology, Inc.
-------------------------------------------------------------------------
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/



This topic has been closed for replies.

3 replies

Inspiring
February 13, 2008
Thanks everyone! Just can't seem to walk through logical issues today.

--
Bryan Ashcraft (remove BRAIN to reply)
Web Application Developer
Wright Medical Technology, Inc.
-------------------------------------------------------------------------
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/


"Bash" <bashcraft@wmtBRAIN.com> wrote in message
news:fov35m$58j$1@forums.macromedia.com...
>I just can't seem to wrap my head around this one today.
> I need to find the date for a specific day. For example, the first Friday
> in November. I can't seem to work out that first Friday part.
>
> --
> Bryan Ashcraft (remove BRAIN to reply)
> Web Application Developer
> Wright Medical Technology, Inc.
> -------------------------------------------------------------------------
> Macromedia Certified Dreamweaver Developer
> Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/
>
>
>


Inspiring
February 13, 2008
I have a similar requirement to know the last Saturday and Sunday of the month. This is how I do it.

LastSat = createdate(year(now()),month(now()),daysinmonth(now()));
LastSun = LastSat;

while (DayofWeek(LastSat) is not 7)
LastSat = DateAdd("d", -1, LastSat);

while (DayofWeek(LastSun) is not 1)
LastSun = DateAdd("d", -1, LastSun);
Inspiring
February 13, 2008
You might try this UDF.
http://www.cflib.org/udf.cfm?ID=1258
Participating Frequently
February 13, 2008
There are many ways to do this, but here is one method that comes to mind. The first Friday of any month must be in the first 7 days so loop through the first 7 days of the month, and when the day of week = 6, you have your date.

<cfset mnth = "11">
<cfset yr = "2008">

<cfloop from="1" to="7" index="i">
<cfset dte = CreateDate(yr, mnth, i)>
<cfset weekday = DatePart("w", dte)>
<cfif weekday EQ "6">
<cfoutput>
The first Friday in month #mnth# is #dateFormat(dte ,"mm/dd/yyyy")#
</cfoutput>
</cfif>
</cfloop>

Phil