[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

display 1st and last in group (date format)

<cfoutput  group="CalendarDate"><cfif #Recurring# is "yes">#dateformat(CalendarDate,'mmmm d, yyyy')#<cfelse>sdfsdf</cfif></cfoutput>

i need to be able to display the 1st and last date (this is part of <cfoutput query="LastName"> so i can't use output query.
0
phillystyle123
Asked:
phillystyle123
  • 5
  • 5
1 Solution
 
rstorey2079Commented:
You need to post more information.  What is not working? What is the structure of the query result set that you are trying to output?
0
 
phillystyle123Author Commented:
funny, i was just getting ready to do that when i got your comment -

in the code below i have  group="CalendarDate" nested in <cfoutput query="eventtypes" group="Eventname">

my query:
<cfquery name="eventtypes" datasource="#dsn#">
      select ETImage, ETImageOver, EventID,GrayNote, Eventname, ETHeaderImage, ETDesc, EventImage, CalendarDate, Subtitle, LongName, Recurring from eventtypes, calendar
      where calendar.EventType=EventID AND EventID = "#url.EventID#"
            order by CalendarDate Asc</cfquery>

my output:
<cfoutput query="eventtypes" group="Eventname">......
<cfoutput  group="CalendarDate"><cfif #Recurring# is "yes">#dateformat(CalendarDate,'mmmm d, yyyy')#<br><cfelse>#dateformat(CalendarDate,'mmmm d, yyyy')#</cfif></cfoutput>

if <#Recurring# is "yes"> is true there are at least 2 usually more dates listed.  

i need to show ONLY the 1st and last recurring date for each Eventname.  AND instead of

January 28, 2004
January 31, 2004

my formatting has to output this:

January 28-31, 2004

if it crosses over a month it has to look like this:


October 28-November 2, 2003
0
 
danrosenthalCommented:
try this one...

<cfoutput query="eventtypes" group="Eventname">
      <cfoutput  group="CalendarDate">
            <CFSET startdate = 0>
            <CFIF Recurring is "yes">
                  <CFIF startdate neq 0>
                      <CFSET startdate = CalendarDate>
                  <CFSET>
                      <CFSET enddate = CalendarDate>
                  </CFIF>
            </CFIF>
      </cfoutput>
      RANGE:
      <CFIF month(startdate) eq month(enddate) >
      #dateformat(startdate,'mmmm')# #dateformat(startdate,'d')#-#dateformat(startdate,'d, yyyy')#
      <CFELSE>
      #dateformat(startdate,'mmmm d')#-#dateformat(startdate,'mmmm d, yyyy')#
      </cfif>
</cfoutput>
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
phillystyle123Author Commented:
i got this error:

Error Diagnostic Information
Attribute set validation error in tag CFSET

The tag has an invalid attribute combination: the following required attributes have not been provided: (INSIDETEXT).

The error occurred while processing an element with a general identifier of (CFSET), occupying document position (510:16) to (510:22).

The specific sequence of files included or processed is:
/usr/local/etc/httpd/htdocs/calartsweb/redcat/calendar/series.cfm      

0
 
danrosenthalCommented:
which line of code relates to your line 510?
0
 
phillystyle123Author Commented:
looks like line 510 was this:

<CFSET>

i got rid of it and now i'm getting this error:

An error occurred while evaluating the expression:


 month(startdate) eq month(enddate)



Error near line 515, column 28.
--------------------------------------------------------------------------------

Error resolving parameter ENDDATE

0
 
danrosenthalCommented:
oh...CFSET should have been CFELSE, and enddate is not getting set all the time....
so just try this one instead..

<cfoutput query="eventtypes" group="Eventname">
     <cfoutput  group="CalendarDate">
          <CFSET startdate = 0>
          <CFIF Recurring is "yes">
               <CFIF startdate neq 0>
                   <CFSET startdate = CalendarDate>
                   <CFSET enddate   = CalendarDate>
               <CFELSE>
                   <CFSET enddate   = CalendarDate>
               </CFIF>
          </CFIF>
     </cfoutput>
     RANGE:
     <CFIF month(startdate) eq month(enddate) >
     #dateformat(startdate,'mmmm')# #dateformat(startdate,'d')#-#dateformat(startdate,'d, yyyy')#
     <CFELSE>
     #dateformat(startdate,'mmmm d')#-#dateformat(startdate,'mmmm d, yyyy')#
     </cfif>
     <BR>
</cfoutput>
0
 
danrosenthalCommented:
ignore that last post...try this one...

<cfoutput query="eventtypes" group="Eventname">
     <CFSET startdate = 0>
     <CFSET enddate = 0>
     <cfoutput  group="CalendarDate">
          <CFIF Recurring is "yes">
               <CFIF startdate eq 0>
                   <CFSET startdate = CalendarDate>
                   <CFSET enddate   = CalendarDate>
               <CFELSE>
                   <CFSET enddate   = CalendarDate>
               </CFIF>
          </CFIF>
     </cfoutput>
     RANGE:
       <CFIF ISDATE(startdate) AND ISDATE(enddate)>
           <CFIF month(startdate) eq month(enddate) >
           #dateformat(startdate,'mmmm')# #dateformat(startdate,'d')#-#dateformat(startdate,'d, yyyy')#
           <CFELSE>
           #dateformat(startdate,'mmmm d')#-#dateformat(startdate,'mmmm d, yyyy')#
           </cfif>
      <CFELSE>
            (Not Valid)
      </cfif>
      <BR>
</cfoutput>
0
 
phillystyle123Author Commented:
i think you're getting really really close here:

for dates that aren't recurring my ouput looks like this:

RANGE: (Not Valid)


John Oswald and the Rascali Klepitoire

for recurring dates i'm getting:

RANGE: May 1-1, 2004


Indian and American Creative Crossover  (it should be May 1 and May 2)

the formatting is perfect though.
0
 
danrosenthalCommented:
one more stab at it...

<cfoutput query="eventtypes" group="Eventname">
      <CFSET startdate = 0>
      <CFSET enddate = 0>
      <cfoutput  group="CalendarDate">
            <CFIF startdate eq 0>
                  <CFSET startdate = CalendarDate>
                  <CFSET enddate   = CalendarDate>
            <CFELSE>
                  <!--- not sure if this recurring check is necessary, feel free to remove it --->
                  <CFIF Recurring is "yes">
                        <CFSET enddate   = CalendarDate>
                  </CFIF>
            </CFIF>
      </cfoutput>
      RANGE:
      <CFIF ISDATE(startdate) AND ISDATE(enddate)>
            <CFIF startdate eq enddate>
                  #dateformat(startdate,'mmmm d, yyyy')#
            <CFELSEIF month(startdate) eq month(enddate)>
                  #dateformat(startdate,'mmmm d')#-#dateformat(enddate,'d, yyyy')#
            <CFELSE>
                  #dateformat(startdate,'mmmm d')#-#dateformat(enddate,'mmmm d, yyyy')#
            </cfif>
      <CFELSE>
            (Not Valid)
      </cfif>
      <BR>
</cfoutput>
0
 
phillystyle123Author Commented:
you got it dan!!!!!!!!  thanks so much for the help - truly appreciated - worked perfectly!!!!
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now