4 Replies Latest reply on Jun 28, 2006 8:43 AM by primalx2003 Branched to a new discussion.

    Date/Time Sheet Application

      I need to create a timesheet application. I am having trouble creating the time slots for the date entries. I need to figure out the week and output the days for that week. For instance, this week is 26. Therefore I need the application to spillout the dates from Sunday the 25 of June through the 1st of July.

      I used the following to breakup the date:

      <cfset tday = DateFormat(Now(), "mm/dd/yyyy")>
      <cfset yr = DatePart("yyyy", tday)>
      <cfset dy = DatePart("d", tday)>
      <cfset mn = DatePart("m", tday)>
      <cfset wday = DatePart("w", tday)>
      <cfset wk = DatePart("ww", tday)>

      I am confused on how to get the dates to be outputed from the week we are in.

      Please help.

      Thank you very much.

      Sevor Klu
        • 1. Re: Date/Time Sheet Application
          elDonrico Level 1
          Depending on which day you want to start the row on...

          <!--- find today's day and discover how many days its been since saturday. subtract 5 days from friday to get the date of sunday --->
          <cfif DateFormat(NOW(), 'DDDD') EQ 'Friday'>
          <CFSET startDate = DateAdd('d',-5, Now())>
          <cfelseif DateFormat(NOW(), 'DDDD') EQ 'Thursday'>
          <CFSET startDate = DateAdd('d',-4, Now())>
          <cfelseif DateFormat(NOW(), 'DDDD') EQ 'Wednesday'>
          <CFSET startDate = DateAdd('d',-3, Now())>
          <cfelseif DateFormat(NOW(), 'DDDD') EQ 'Tuesday'>
          <CFSET startDate = DateAdd('d',-2, Now())>
          <cfelseif DateFormat(NOW(), 'DDDD') EQ 'Monday'>
          <CFSET startDate = DateAdd('d',-1, Now())>
          <cfelseif DateFormat(NOW(), 'DDDD') EQ 'Sunday'>
          <CFSET startDate = DateAdd('d',-0, Now())>
          <cfelseif DateFormat(NOW(), 'DDDD') EQ 'Saturday'>
          <CFSET startDate = DateAdd('d',-6, Now())>

          then do something like this to output...

          <TABLE width="80%" cellpadding="0" cellspacing="0" border="1">
          <TR bgcolor="e6e6e6">
          <TR bgcolor="ffffff">
          <!--- loop from 0 to 6 (sunday to saturday) --->
          <CFLOOP FROM="0" TO="6" STEP="1" INDEX="day">
          <CFSET thisDate = DateAdd('d', day, startDate)>
          <CFQUERY NAME="thisTime" DBTYPE="QUERY">
          SELECT InDate, OutDate
          FROM your dbtable
          WHERE InDate >= <cfqueryparam value="#DateFormat(thisDate,'m/d/yyyy')#" cfsqltype="cf_sql_date">
          AND InDate <= <cfqueryparam value="#dateAdd('d', 1, thisDate)#" cfsqltype="cf_sql_date">

          <TD><div align="center"><cfoutput>#thistime.InDate# - #thistime.OutDate#</cfoutput></div><br></TD>


          this should start you in the right direction, the key here is what data are you outputing. or are you just wanting to output a calendar like week?
          • 2. Re: Date/Time Sheet Application
            web-spinners Level 1
            Below are two methods to output the days for a week. The first uses now as the start.
            The second uses the Week number.
            • 3. Re: Date/Time Sheet Application
              Dan Bracuk Level 5
              startdate = now();
              while(dayofweek(startdate) gt 1) // 1 is Sunday
              startdate = dateadd("d", -1, startdate);

              enddate = dateadd("d", 7, startdate);

              That should get you started.
              • 4. Re: Date/Time Sheet Application
                primalx2003 Level 1
                Thank you all for your help. It works.

                Sevor Klu