Solved

display 1st and last in group (date format)

Posted on 2003-10-28
11
210 Views
Last Modified: 2013-12-24
<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
Comment
Question by:phillystyle123
  • 5
  • 5
11 Comments
 
LVL 1

Expert Comment

by:rstorey2079
Comment Utility
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
 

Author Comment

by:phillystyle123
Comment Utility
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
 
LVL 15

Expert Comment

by:danrosenthal
Comment Utility
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
 

Author Comment

by:phillystyle123
Comment Utility
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
 
LVL 15

Expert Comment

by:danrosenthal
Comment Utility
which line of code relates to your line 510?
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:phillystyle123
Comment Utility
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
 
LVL 15

Expert Comment

by:danrosenthal
Comment Utility
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
 
LVL 15

Expert Comment

by:danrosenthal
Comment Utility
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
 

Author Comment

by:phillystyle123
Comment Utility
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
 
LVL 15

Accepted Solution

by:
danrosenthal earned 125 total points
Comment Utility
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
 

Author Comment

by:phillystyle123
Comment Utility
you got it dan!!!!!!!!  thanks so much for the help - truly appreciated - worked perfectly!!!!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now