• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Getting date for a specific day

LEGEND ,
Feb 13, 2008 Feb 13, 2008

Copy link to clipboard

Copied

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/



TOPICS
Advanced techniques

Views

336

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Feb 13, 2008 Feb 13, 2008

Copy link to clipboard

Copied

You might try this UDF.
http://www.cflib.org/udf.cfm?ID=1258

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Feb 13, 2008 Feb 13, 2008

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 13, 2008 Feb 13, 2008

Copy link to clipboard

Copied

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);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 13, 2008 Feb 13, 2008

Copy link to clipboard

Copied

LATEST
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/
>
>
>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation