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

Hide WeekEnds Dates

Guest
Jul 28, 2006 Jul 28, 2006

Copy link to clipboard

Copied


How can I use the ( #DayofWeek(datefield)# NEQ 1 or 7 ) on the following loop code to remove (not display) weekends dates?

TOPICS
Advanced techniques

Views

403

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

correct answers 1 Correct answer

Deleted User
Jul 28, 2006 Jul 28, 2006


Gotcha Phil, I misunderstood.

Anyway, here is the code that worked for my loop:

<!--- Looping queries to get range of dates and filtering out Weekend dates --->
<cfloop from="#GetStartDate.StartDate#" to="#GetEndDate.EndDate#" index="i">
<cfif (dayOfWeek(i) gt 1) AND (dayOfWeek(i) lt 7)>
<cfset variables.keyvalue = DateFormat(i, "YYYY/MM/DD")>
<cfset structDaysTemplate["#variables.keyvalue#"] = "">
<cfset structRooms.Days["#variables.keyvalue#"] = "#DateFormat(i, "MM/DD")#">
<cfset ...

Votes

Translate

Translate
LEGEND ,
Jul 28, 2006 Jul 28, 2006

Copy link to clipboard

Copied

The general idea is
<cfif DayofWeek(datefield) is not 1
or DayofWeek(datefield) is not 7>

Or you could be positive about the whole thing and do this
<cfif ListFind("2,3,4,5,6", DayofWeek(datefield)) is true>

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
Guest
Jul 28, 2006 Jul 28, 2006

Copy link to clipboard

Copied

Correct Dan, but where would I put this code within my loop. I kept trying and it wasn't working correctly.
I have 2 queries, one that sorts the StratDate field in asend order to get the earliest date, and another that sorts the Enddate desend to get the latest date and I loop those values to get my range.

So while it's looping through to get my values, I want it to ignore the weekend dates before it sets its value.

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 ,
Jul 28, 2006 Jul 28, 2006

Copy link to clipboard

Copied

quote:

The general idea is
<cfif DayofWeek(datefield) is not 1
or DayofWeek(datefield) is not 7>


Dan, wouldnt' that be AND?

<cfif DayofWeek(datefield) is not 1 AND DayofWeek(datefield) is not 7>


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
Guest
Jul 28, 2006 Jul 28, 2006

Copy link to clipboard

Copied

Phil,

It would be 1 OR 7, because were filtering for 2 values. If you said 1 AND 7, it won't filter because the value (DayofWeek) for a specific Date will never be 1 AND 7. Meaning the date 10/15/2006 can never have a DayofWeek value of 1 (Sunday) and 7 (Saturday). It will be one or the other.

Hope that helps.

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 ,
Jul 28, 2006 Jul 28, 2006

Copy link to clipboard

Copied

I was thinking in terms of NOT displaying weekend dates, rather than filtering FOR them. Notice that I didn't say 1 AND 7, but that the statement says NOT 1 AND NOT 7, which is quite different.

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 ,
Jul 28, 2006 Jul 28, 2006

Copy link to clipboard

Copied

quote:

Originally posted by: paross1
quote:

The general idea is
<cfif DayofWeek(datefield) is not 1
or DayofWeek(datefield) is not 7>

Dan, wouldnt' that be AND?
<cfif DayofWeek(datefield) is not 1 AND DayofWeek(datefield) is not 7>



Of course it would.

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 ,
Jul 28, 2006 Jul 28, 2006

Copy link to clipboard

Copied

disregard

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
Guest
Jul 28, 2006 Jul 28, 2006

Copy link to clipboard

Copied

LATEST


Gotcha Phil, I misunderstood.

Anyway, here is the code that worked for my loop:

<!--- Looping queries to get range of dates and filtering out Weekend dates --->
<cfloop from="#GetStartDate.StartDate#" to="#GetEndDate.EndDate#" index="i">
<cfif (dayOfWeek(i) gt 1) AND (dayOfWeek(i) lt 7)>
<cfset variables.keyvalue = DateFormat(i, "YYYY/MM/DD")>
<cfset structDaysTemplate["#variables.keyvalue#"] = "">
<cfset structRooms.Days["#variables.keyvalue#"] = "#DateFormat(i, "MM/DD")#">
<cfset structRooms.Totals["#variables.keyvalue#"] = 0>
</cfif>
</cfloop>

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