Problem w/ calendar help!!

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Problem w/ calendar help!!

    this code works for every month BUT December. What's the problem please HELP
    THX

    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
    }
    //-->
    </script>


    <cfparam name="cal_day" default=1>
    <cfparam name="cal_Year" default=#Year(Now())#>
    <cfif ISDefined("cal_month") Is Not True>
    <cfparam name="cal_month" default=#month(Now())#>
    <cfelse>
    <cfset EntryDate = "#Dateformat(cal_month,"dd/mm/yyyy")#">



    </cfif>

    <cfparam name="first_of_mon" default="#cal_month#-01-#Year(Now())#">
    <cfparam name="today" default=#dateformat(first_of_mon)#>
    <cfparam name="startno" default=#DayofYear(today + DayofWeek(today))#>
    <cfparam name="endno" default=#DayofYear(startno + daysinmonth(cal_month) +
    DayofWeek(today))#>
    <cfparam name="loop_counter" default=#startno#>

    <cfif cal_month is '1'> <cfset Mdate = 'January'> <cfelse> </cfif>
    <cfif cal_month is '2'> <cfset Mdate = 'February'> <cfelse> </cfif>
    <cfif cal_month is '3'> <cfset Mdate = 'March'> <cfelse> </cfif>
    <cfif cal_month is '4'> <cfset Mdate = 'April'> <cfelse> </cfif>
    <cfif cal_month is '5'> <cfset Mdate = 'May'> <cfelse></cfif>
    <cfif cal_month is '6'> <cfset Mdate = 'June'> <cfelse></cfif>
    <cfif cal_month is '7'> <cfset Mdate = 'July'> <cfelse></cfif>
    <cfif cal_month is '8'> <cfset Mdate = 'August'> <cfelse></cfif>
    <cfif cal_month is '9'> <cfset Mdate = 'September'> <cfelse></cfif>
    <cfif cal_month is '10'> <cfset Mdate = 'October'> <cfelse></cfif>
    <cfif cal_month is '11'> <cfset Mdate = 'November'> <cfelse></cfif>
    <cfif cal_month is '12'> <cfset Mdate = 'December'> <cfelse></cfif>

    <table width="650" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td width="18%"><cfinclude template="left_calendar.cfm"></td>
    <td width="82%">

    <div align="left">
    <cfoutput>
    <cfif ISDefined('URL.EntryDate') is Not True>
    <B class="DLargeFont">#Mdate# #year(now())#</B><BR/>
    <cfelse>
    <B class="DLargeFont">
    #Mdate# #year(now())#
    </B><BR/>
    </cfif>


    Select Month:<select name="cal_month"
    onChange="MM_jumpMenu('parent',this,0)">
    <option value="?"> Select Month </option>

    <option value="?EntryDate=01/01/#Year(now())#&cal_month=1">January
    #Year(now())#
    </option>
    <option
    value="?EntryDate=02/01/#Year(now())#&cal_month=2">February #Year(now())#
    </option>
    <option value="?EntryDate=03/01/#Year(now())#&cal_month=3">March
    #Year(now())#
    </option>
    <option value="?EntryDate=04/01/#Year(now())#&cal_month=4">April
    #Year(now())#
    </option>
    <option value="?EntryDate=05/01/#Year(now())#&cal_month=5">May
    #Year(now())#
    </option>
    <option value="?EntryDate=06/01/#Year(now())#&cal_month=6">June
    #Year(now())#
    </option>
    <option value="?EntryDate=07/01/#Year(now())#&cal_month=7">July
    #Year(now())#
    </option>
    <option value="?EntryDate=08/01/#Year(now())#&cal_month=8">August
    #Year(now())#
    </option>
    <option
    value="?EntryDate=09/01/#Year(now())#&cal_month=9">September #Year(now())#
    </option>
    <option
    value="?EntryDate=10/01/#Year(now())#&cal_month=10">October #Year(now())#
    </option>
    <option
    value="?EntryDate=11/01/#Year(now())#&cal_month=11">November #Year(now())#
    </option>
    <option
    value="?EntryDate=12/01/#Year(now())#&cal_month=12">December #Year(now())#
    </option>

    </cfoutput> </div>


    </td>
    </tr>
    </table>
    <table width="650" height="473" border="1" align="center" cellpadding="2"
    cellspacing="0" bordercolor="e9e9e9">
    <cfoutput>
    <tr bgcolor="E9E9E9">
    <th width="15%" height="25">Sun</th>
    <th width="15%">Mon</th>
    <th width="15%">Tue</th>
    <th width="15%">Wed</th>
    <th width="15%">Thu</th>
    <th width="15%">Fri</th>
    <th width="15%">Sat</th>
    </tr>
    <tr>

    <cfloop condition="#startno# LT #endno#">
    <cfif #Dayofweek(today)# EQ #cal_day#>
    <cfset mm = "#DateFormat(today,"mm/dd/yyyy")#">


    <CFQUERY NAME="lookupoutage" DATASOURCE="Tracking">
    SELECT StartDate, InfoID, OptionType, CustomerName,
    Description,StartTime,EndTime,EndDate
    FROM INfo
    Where ((OptionType = 'Outage' OR OptionType = 'Issue'))
    AND StartDate = '#mm#'
    <cfif ISDefined('URL.EntryDate')>
    AND Month(StartDate) = '#month(URL.EntryDate)#'
    </cfif>
    </CFQUERY>


    <CFQUERY NAME="lookupCustomer" DATASOURCE="CPS_Tracking">
    SELECT CustID,CustomerName
    FROM Customer
    Where CustID = '#lookupoutage.CustomerName#'
    </CFQUERY>

    <cfset start = "#dateformat(lookupoutage.StartDate,"mm/dd/yy")# -
    #timeformat(lookupoutage.Starttime)#">
    <cfset End = "#dateformat(lookupoutage.EndTime,"mm/dd/yy")# -
    #timeformat(lookupoutage.EndTime)#">
    <cfif lookupoutage.endtime is "">
    <cfelse>
    <cfset MinCount =
    #DateDiff('s',lookupoutage.Starttime,lookupoutage. endtime)#>
    <cfset Duration = MinCount/60>
    <cfset newDuration = #DecimalFormat(Duration*000001)#>
    </cfif>

    <td align="center" bgcolor=<cfif mm is
    '#Dateformat(lookupoutage.StartDate,"mm/dd/yyyy")#'>
    <cfif lookupoutage.OptionType EQ 'Outage'>"FF0000"<cfelse>"FFFF00"</cfif>
    <cfelse>"009933"</cfif>>
    #DateFormat(mm,"DD")#
    <cfif mm is '#Dateformat(lookupoutage.StartDate,"mm/dd/yyyy")#'>
    <BR/>
    <b title="#lookupoutage.Description#"><a href="##"
    onclick="MM_openBrWindow('Outage_Drilldown.cfm?Inf oID=#lookupoutage.InfoID#','',
    'scrollbars=yes,width=400,height=400')">#lookupCus tomer.CustomerName#</a></b>
    <cfif lookupoutage.endtime is ""> <cfelse>Duration-(#newDuration#)</cfif>
    <cfelse></cfif>


    </td>
    <cfset today = "#Dateformat(today+1)#">
    <cfelse>
    <td></td>
    </cfif>
    <cfif #cal_day# EQ 7>
    </tr><tr>
    <cfset cal_day = 1>
    <cfelse>
    <cfset cal_day = #cal_day# + 1>
    </cfif>
    <cfset cal_month = #Month(today)#>
    <cfset startno = #startno# +1>
    </cfloop>
    <cfloop condition="cal_day LTE 7">
    <cfif #cal_day# LTE 7>
    <td> </td>
    </cfif>
    <cfset cal_day = #cal_day# +1>
    </cfloop>



    </tr>

    </cfoutput>
    </table>

    <cfinclude template="calendar_Details.cfm">

    Scooter_T Guest

  2. Similar Questions and Discussions

    1. XML Flash Calendar Problem
      I have a flash xml calendar. I am building a website all in Flash, but when I try to use the loadMovie function to load the calendar's swf file...
    2. Printing Calendar Problem
      I have a teacher that has a problem when printing her calendar from her web page. When she prints, none of the date boxes or shading prints. You...
    3. 2006 calendar needed for photo calendar
      I want to start work on a 2006 calendar featuring my own photographs. In Photoshop there used to be a calendar-creating feature that worked well,...
    4. Problem with Calendar webcontrol in a web custom control
      I'm building a web custom control, that should render out a calendar webcontrol. I'm using the following code... protected override void...
    5. Problem with displaying a red dot in a event calendar
      Hi, guys, I am trying to build an event calendar using asp, i want to display a redot whenever there is an event on that day. i built the ms access...
  3. #2

    Default Re: Problem w/ calendar help!!

    What specifically is not working? The first thing that jumps out is

    <cfset EntryDate = "#Dateformat(cal_month,"dd/mm/yyyy")#"> won't work.
    Presumably cal_month is 1 thru 12.. not a date. Whether that's a problem,
    I don't know.


    OldCFer Guest

  4. #3

    Default Re: Problem w/ calendar help!!

    I was hoping you would see this OldCFer!!


    cal_month is 1 - 12, is calendar works gret, but if current date is december or user selects december

    Scooter_T Guest

  5. #4

    Default Re: Problem w/ calendar help!!

    I don't know how this is working at all. You are using the date functions
    incorrectly.
    daysinmonth(cal_month) will aways be 31. You have to use *Dates*, not 1-12 for
    those functions otherwise CF thinks you are passing Dec-1899, Jan-2000 dates.
    Run the following code and you'll see what I mean.

    <cfloop index="cal_month" from="1" to="12">
    <cfoutput>#daysinmonth(cal_month)#
    #DateFormat(cal_month,"mm/dd/yyyy")#<br></cfoutput>
    </cfloop>

    OldCFer Guest

  6. #5

    Default Re: Problem w/ calendar help!!

    <!---Larry - copy below see example.. Change the date on your box to dec then
    refresh it---> <cfparam name='cal_day' default=1> <cfparam name='cal_Year'
    default=#Year(Now())#> <cfif ISDefined('cal_month') Is Not True> <cfparam
    name='cal_month' default=#month(Now())#> <cfelse> <cfset EntryDate =
    '#Dateformat(cal_month,'dd/mm/yyyy')#'> </cfif> <cfparam name='first_of_mon'
    default='#cal_month#-01-#Year(Now())#'> <cfparam name='today'
    default=#dateformat(first_of_mon)#> <cfparam name='startno'
    default=#DayofYear(today + DayofWeek(today))#> <cfparam name='endno'
    default=#DayofYear(startno + daysinmonth(cal_month) + DayofWeek(today))#>
    <cfparam name='loop_counter' default=#startno#> <table width='650' border='0'
    align='center' cellpadding='0' cellspacing='0'> <tr> <td
    width='18%'></td> <td width='82%'> </td> </tr> </table>
    <table width='650' height='473' border='1' align='center' cellpadding='2'
    cellspacing='0' bordercolor='e9e9e9'> <cfoutput> <tr bgcolor='E9E9E9'>
    <th width='15%' height='25'>Sun</th> <th width='15%'>Mon</th>
    <th width='15%'>Tue</th> <th width='15%'>Wed</th> <th
    width='15%'>Thu</th> <th width='15%'>Fri</th> <th
    width='15%'>Sat</th> </tr> <tr> <cfloop condition='#startno# LT #endno#'>
    <cfif #Dayofweek(today)# EQ #cal_day#> <cfset mm =
    '#DateFormat(today,'mm/dd/yyyy')#'> <td align='center'
    bgcolor='e9e9e9'>#dateformat(mm,'dd')#</td> <cfset today =
    '#Dateformat(today+1)#'> <cfelse> <td></td> </cfif> <cfif #cal_day# EQ 7>
    </tr><tr> <cfset cal_day = 1> <cfelse> <cfset cal_day = #cal_day# + 1> </cfif>
    <cfset cal_month = #Month(today)#> <cfset startno = #startno# +1> </cfloop>
    <cfloop condition='cal_day LTE 7'> <cfif #cal_day# LTE 7> <td>
    </td> </cfif> <cfset cal_day = #cal_day# +1> </cfloop> </tr> </cfoutput>
    </table>

    Scooter_T Guest

  7. #6

    Default Re: Problem w/ calendar help!!

    As I said before, you are using your date functions incorrectly. They want
    dates not numbers
    The reason Dec is not working is because StartNo is larger than Endno to begin
    with. Look at
    the way you are calculating EndNo:
    <cfparam name="endno" default=#DayofYear(startno + daysinmonth(cal_month) +
    DayofWeek(today))#>
    The way CF interprets this is:
    <cfparam name="endno" default=#DayofYear(340 + daysinmonth("1/11/1900") +
    DayofWeek(today))#>
    The Date it's actually going to use for the DayOfYear() function is:
    Dec-30-1899 + 340 day + 31 Days + DayofWeek(today)
    which works out to 10-Jan-1901, which obviously is a DayOfYear of 10.

    Why don't you just create the start date for the month, and increment it up to
    the DaysInMonth for that
    particular date, or get the DayOfYear of the first of the month and DayOfYear
    of the end of the month
    and use those?

    OldCFer Guest

  8. #7

    Default Re: Problem w/ calendar help!!

    Larry -


    Thx for the help

    i am still having problems w/ the syntax,

    Scooter_T Guest

  9. #8

    Default Re: Problem w/ calendar help!!

    This will build the basic calendar.

    <cfset cal_month = 2>
    <cfparam name="first_of_mon" default="#CreateDAte(Year(Now()),cal_month,1)#">

    <table width="650" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td width="18%"></td>
    <td width="82%">


    </td>
    </tr>
    </table>
    <table width="650" height="473" border="1" align="center" cellpadding="2"
    cellspacing="1" bordercolor="e9e9e9">
    <cfoutput>
    <tr bgcolor="E9E9E9">
    <th width="15%" height="25">Sun</th>
    <th width="15%">Mon</th>
    <th width="15%">Tue</th>
    <th width="15%">Wed</th>
    <th width="15%">Thu</th>
    <th width="15%">Fri</th>
    <th width="15%">Sat</th>
    </tr>
    <tr bgcolor="E9E9E9">
    <cfset EmptyStart = DayofWeek(first_of_mon) - 1>
    <cfloop index="i" from="1" to="#EmptyStart#">
    <td></td>
    </cfloop>

    <cfset cal_day = 1>
    <cfloop condition="#cal_day# LTE #DaysInMonth(first_of_mon)#">
    <cfset mm = CreateDAte(Year(first_of_mon),cal_month,cal_day)>
    <td align="center" bgcolor="e9e9e9">#dateformat(mm,'d')#</td>
    <cfif NOT DayofWeek(mm) MOD 7>
    </tr><tr bgcolor="e9e9e9">
    </cfif>
    <cfset cal_day=cal_day + 1>
    </cfloop>
    <cfset EmptyEnd = 7 - DayofWeek(mm)>
    <cfloop index="i" from="1" to="#EmptyEnd#">
    <td></td>
    </cfloop>
    </tr>

    </cfoutput>
    </table>

    OldCFer Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139