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

Date/Time Sheet Application

Explorer ,
Jun 28, 2006 Jun 28, 2006

Copy link to clipboard

Copied

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
TOPICS
Advanced techniques

Views

636

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

Explorer , Jun 28, 2006 Jun 28, 2006
Below are two methods to output the days for a week. The first uses now as the start.
The second uses the Week number.

Votes

Translate

Translate
Participant ,
Jun 28, 2006 Jun 28, 2006

Copy link to clipboard

Copied

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())>
</cfif>

then do something like this to output...

<TABLE width="80%" cellpadding="0" cellspacing="0" border="1">
<TR bgcolor="e6e6e6">
<TD>Sun</TD>
<TD>Mon</TD>
<TD>Tues</TD>
<TD>Wed</TD>
<TD>Thur</TD>
<TD>Fri</TD>
<TD>Sat</TD>
</TR>
<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">
</CFQUERY>

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

</CFLOOP>
</TR>
</TABLE>

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?

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
Explorer ,
Jun 28, 2006 Jun 28, 2006

Copy link to clipboard

Copied

Below are two methods to output the days for a week. The first uses now as the start.
The second uses the Week number.

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

Copy link to clipboard

Copied

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.

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
Explorer ,
Jun 28, 2006 Jun 28, 2006

Copy link to clipboard

Copied

LATEST
Thank you all for your help. It works.


Sevor Klu

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