Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
Earion1 #1
Help needed with a date function problem
Hi everyone..
I have a custom tag titled "thisdate"
My application calls for the week to end on Friday, so my date display
looks like... saturday (date) sunday (date) etc.. ending with Friday.
However, when my code displays, the end of the week, (Friday) reads LAST
friday's date as opposed to this upcomming Friday's date.
I am at a lost... can anyone look at the custom tag code and the page code
and see where I am making the mistake here?
Any help would be appreciated.. Thanks!
thisdate custom tag
<cfset todayfoward = attributes.time>
<cfset todaybackward = attributes.time>
<cfset theDayofWeek = attributes.theDayofWeek>
<cfset foward = false>
<CFLOOP Index = "i" From="1" to="7">
<cfif dateformat(todayfoward,"dddd") is theDayofWeek><cfset
foward=true><cfbreak></cfif>
<cfif dateformat(todaybackward,"dddd") is theDayofWeek><cfset
foward=false><cfbreak></cfif>
<cfset todayfoward=dateadd('d',1,todayfoward)>
<cfset todaybackward=dateadd('d',-1,todaybackward)>
</CFLOOP>
<cfif foward>
<cfoutput>#DateFormat(todayfoward,"dddd mmmm d, yyyy")#</cfoutput>
<cfelse>
<cfoutput>#DateFormat(todaybackward,"dddd mmmm d, yyyy")#</cfoutput>
</cfif>
Code to display...
For the week ending <lf:thisdate theDayofWeek="friday" time="#now()#">
<th scope="col"><lf:thisdate theDayofWeek="saturday" time="#now()
#"></th>
<th scope="col"><lf:thisdate theDayofWeek="sunday" time="#now()#"></th>
<th scope="col"><lf:thisdate theDayofWeek="monday" time="#now()#"></th>
<th scope="col"><lf:thisdate theDayofWeek="tuesday" time="#now()
#"></th>
<th scope="col"><lf:thisdate theDayofWeek="wednesday" time="#now()
#"></th>
<th scope="col"><lf:thisdate theDayofWeek="thursday" time="#now()
#"></th>
<th scope="col"><lf:thisdate theDayofWeek="friday" time="#now()#"></th>
:confused;
Earion1 Guest
-
#39245 [NEW]: date function generate wrong date with 1162083600 timestamp
From: lohner at aldea dot hu Operating system: Linux PHP version: 5.1.6 PHP Bug Type: Date/time related Bug description: ... -
date control ?? Help needed
is there a simple control to add in my custom server control to select a date. On my page I show several fields and I prefer something like a... -
Problem with adding text to emails using the date function
Hi, using the folling line fo code i am trying to add some text to an email: $subject .= "\nBooking Commences: ".date("jS F Y \a\t H\:i",... -
HELP! Needed with Fox Pro date math
I am accessing a Fox Pro database through ODBC in ASP. I have a table with two dates in it. A start date and an end date. I need to create a... -
Calculating Date Differences Help Needed
What's a good way to calculate the number of days between two dates in the following format: 2003-07-15 2003-08-02 I've looked at the PHP... -
OldCFer #2
Re: Help needed with a date function problem
You can use the following to give you a Saturday thru Friday date display.
<cfset TheDate = "4/26/2005">
<cfset StartSaturday = DateAdd("d", - 6, DateAdd("d",6 -
DayOfWeek(TheDate),TheDate))>
<cfloop index="idx" from="0" to="6">
<cfoutput>#DateFormat(DateAdd("d",idx,StartSaturda y),"dddd mmmm d,
yyyy")#<br></cfoutput>
</cfloop>
If "TheDate" is a Saturday, you will need to figure out how you want to handle
that.
OldCFer Guest



Reply With Quote

