8 Replies Latest reply on Jul 28, 2006 10:21 AM by DJ5MD

    Hide WeekEnds Dates

    DJ5MD

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

        • 1. Re: Hide WeekEnds Dates
          Dan Bracuk Level 5
          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>
          • 2. Hide WeekEnds Dates
            DJ5MD Level 1
            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.
            • 3. Re: Hide WeekEnds Dates
              paross1 Level 2
              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
              • 4. Re: Hide WeekEnds Dates
                DJ5MD Level 1
                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.
                • 5. Hide WeekEnds Dates
                  paross1 Level 2
                  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
                  • 6. Re: Hide WeekEnds Dates
                    Dan Bracuk Level 5
                    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.
                    • 7. Hide WeekEnds Dates
                      paross1 Level 2
                      disregard
                      • 8. Re: Hide WeekEnds Dates
                        DJ5MD Level 1


                        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>