Solved

How to keep from displaying a record when the day is Saturday or Sunday?

Posted on 2002-06-05
2
189 Views
Last Modified: 2013-12-24
I have a calendar cf application.  The query ouputs the proper records to the correct cells in the calendar.  

I want to not output the record if the day is Saturday or Sunday.  Below is the code I currently have.  How can I edit it to work correctly?

<CFLOOP INDEX="ii" FROM="1" TO="#CalDays#">
               <CFIF #ii# GTE #Offset# and #ii# LTE #LastSlot# >
                    <TD BGCOLOR="whitesmoke" valign=top WIDTH="" height="40">
                         <CFOUTPUT ><FONT SIZE="3"

COLOR="black">#day#</FONT><br></cfoutput>
                         <cfoutput query="SearchResults">
   
  <cfset dayofweek = DayOfWeek(Now()) IS "1">
  <cfset dayofweek2 = DayOfWeek(Now()) IS "7">
   <CFIF #Day# greater than '#day(firstout)#' and #Day# less than '#day(lastout)#'>
<CFIF #Day# is not dayofweek>
 <A HREF="default_details.cfm?pk=#pk#"><FONT size="-2" color="red"></FONT><FONT FACE=ARIAL

size="-2">#name# </FONT><FONT FACE=ARIAL SIZE="-2" COLOR="red">#reasonout#</A></FONT><br>
<cfelseif #Day# is not dayofweek2>
   <A HREF="default_details.cfm?pk=#pk#"><FONT size="-2" color="red"></FONT><FONT FACE=ARIAL

size="-2">#name# </FONT><FONT FACE=ARIAL SIZE="-2" COLOR="red">#reasonout#</A></FONT><br>
<cfelse>
</cfif>
</cfif>
                      <CFIF #Day# is '#day(firstout)#'>      
                                 <A HREF="default_details.cfm?pk=#pk#"><FONT FACE=ARIAL size="-2">#name#

</FONT><FONT FACE=ARIAL SIZE="-2" COLOR="red">#reasonout#</A></FONT><br>

                                 <CFelseIF #Day# is '#day(lastout)#'>
                                 <A HREF="default_details.cfm?pk=#pk#"><FONT FACE=ARIAL size="-2">#name#

</FONT><FONT FACE=ARIAL SIZE="-2" COLOR="red">#reasonout#</A></FONT><br>
                           
                      </cfif> </cfoutput>
0
Comment
Question by:g118481
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Expert Comment

by:nathans
ID: 7093622
This is not an answer first I want to comment on a few things.  Hopefully the spacing I used for your post does not get messed up.  I added some comments too.  You need to comment your code it helps you and others maintence it and trouble shoot it.  Also provide Default values for fields passed in this makes it easier for the troubleshooter to help you.  Also if you post code make sure the ending of cfloops, cfifs and others are there.

Hope this helps you get started on solving your problem.


Comment:

      <cfset dayofweek = DayOfWeek(Now()) IS "1">
      <cfset dayofweek2 = DayOfWeek(Now()) IS "7">

If today is Sunday:
dayofweek  = Yes
dayofweek2 = No

If today is Saturday:
dayofweek  = No
dayofweek2 = Yes

All other days
dayofweek  = No
dayofweek2 = No

========================================================
<!--- Start of Loop 1 --->
<!--- CalDays?  Where is CalDays coming from? --->
<CFLOOP INDEX="ii" FROM="1" TO="#CalDays#">

     <!--- Start CFIF 1 --->
  <CFIF #ii# GTE #Offset# and #ii# LTE #LastSlot# > 
    <TD BGCOLOR="whitesmoke" valign=top WIDTH="" height="40">

          <!--- Output Day?  Where is Day coming from? --->
    <CFOUTPUT ><FONT SIZE="3" COLOR="black">#day#</FONT><br></cfoutput>

          <!--- Output Query SearchResults where is that query? --->
    <cfoutput query="SearchResults">

      <cfset dayofweek = DayOfWeek(Now()) IS "1">
      <cfset dayofweek2 = DayOfWeek(Now()) IS "7">

               <!--- Start CFIF 2 --->
               <CFIF #Day# greater than '#day(firstout)#' and #Day# less than '#day(lastout)#'>


                    <!---
                    If this is where your checking to see if this is Saturday or Sunday then you need to know... that both dayofweek and dayofweek2 will equal either yes or no and that is all.
                     --->
                    <!--- Day 1 Sunday --->
        <CFIF #Day# is not dayofweek>
          <A HREF="default_details.cfm?pk=#pk#">
                         <FONT FACE=ARIAL size="-2">#name# </FONT>
                         <FONT FACE=ARIAL SIZE="-2" COLOR="red">#reasonout#</A></FONT>
                         <br>
                    <!--- Day 2 Saturday --->
                    <cfelseif #Day# is not dayofweek2>
                         <A HREF="default_details.cfm?pk=#pk#">
                         <FONT FACE=ARIAL size="-2">#name# </FONT>
                         <FONT FACE=ARIAL SIZE="-2" COLOR="red">#reasonout#</A></FONT>
                         <br>
                    <cfelse>
                         <!--- Blank? --->
                    </cfif>

               <!--- End CFIF 2 --->
               </cfif>

               <!--- What is this? where does firstout come from? --->
      <CFIF #Day# is '#day(firstout)#'>      
        <A HREF="default_details.cfm?pk=#pk#">
                 <FONT FACE=ARIAL size="-2">#name#</FONT>
                 <FONT FACE=ARIAL SIZE="-2" COLOR="red">#reasonout#</A></FONT>
                 <br>
               <!--- What is this? where does lastout come from? --->
               <CFelseIF #Day# is '#day(lastout)#'>
                 <A HREF="default_details.cfm?pk=#pk#">
                 <FONT FACE=ARIAL size="-2">#name#</FONT>
                 <FONT FACE=ARIAL SIZE="-2" COLOR="red">#reasonout#</A></FONT>
                 <br>
         </cfif>
     </cfoutput>



     <!--- End CFIF 1 --->
  </cfif>
<!--- End of Loop 1 --->
</CFLOOP>
========================================================

0
 
LVL 1

Accepted Solution

by:
parekh_minal earned 100 total points
ID: 7205755
Hi,

Hope this will help you.

<cfset today = DateFormat(now(), "dddd")>

<cfif (today eq 'Sunday') OR (today eq 'Saturday')>
    Do not display record
<cfelse>
    Display Record
</cfif>
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question