Help needed with a date function problem

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

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. #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: ...
    2. 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...
    3. 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",...
    4. 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...
    5. 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...
  3. #2

    Default 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

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