listAppend & CHR 32 to create a space not functioning

Hi. I use the following listAppend:


<cfset variables.datestr = ListAppend( variables.datestr, variables.newDate, ', ' & CHR(32) )>

I use the CHR(32) to create a space after the comma in the output but for some reason is it not working. Does anybody has an idea why this isn’t working?

Maybe I’m stupid but I have take the CHR(32) away but still don’t get a space. Can you please tel how to create a space Rudy using listAppend?

from the cfdocs:[indent]ListAppend(list, value [, delimiters ])

delimiters –

A string or a variable that contains one. Character(s) that separate list elements. The default value is comma.

If this parameter contains more than one character, ColdFusion uses only the first character.[/indent]
answers your question?

:cool:

i don’t think you can do what you’re after with ListAppend

try a loop where you simple concatenate each list element onto the end of a string variable

Hi Rudy I lost the plot a bit. How do you mean?

Thank you in advance.

Hi Rudy. Is it not possible to set the date_format in the query and then use the value in a valueList? Because in a valueList you have the option to create a space after the comma?

Hi Rudy. Is it not possible to set the date_format in the query and then use the value in a valueList? Because in a valueList you have the option to create a space after the comma?

i lost the plot a bit – what query?

This is the complete query to output the activity:


      	SELECT
                CL.category_id
          ,	C.language_abbr
          ,	C.category_name
          ,	CH.photo
          ,	AL.activity_id
          ,	AL.activity_persons
          ,	AL.activity_price
          ,	A.language_abbr
          ,	A.activity_name
          ,	A.activity_title
          ,	A.activity_description
          ,	AD.activity_date
          ,	TL.team_leader_id
          ,	TL.team_leader_name_eng
          ,	TL.team_leader_name_gre
          ,	TL.team_leader_description_eng
          ,	TL.team_leader_description_gre
          ,	TLP.photo AS tl_photo
        FROM
                category_list CL
				INNER
        	JOIN categories C
          	ON CL.category_id = C.category_id
           AND C.language_abbr = <cfqueryparam cfsqltype="cf_sql_char" value="#Trim( Session.language )#" />
				INNER
        	JOIN category_headers CH
          	ON CL.category_id = CH.category_id 
				INNER
        	JOIN activity_list AL
          	ON CL.category_id = AL.category_id 
				INNER
        	JOIN activities A
          	ON AL.activity_id = A.activity_id
           AND A.language_abbr = <cfqueryparam cfsqltype="cf_sql_char" value="#Trim( Session.language )#" />
  			INNER
  				JOIN 	activity_dates AD
    				ON	AL.activity_id = AD.activity_id	
        LEFT
        	JOIN team_leader_activities TLA
          	ON AL.activity_id = TLA.activity_id   
				LEFT
        	JOIN team_leaders TL
          	ON TLA.team_leader_id = TL.team_leader_id      
 				LEFT
        	JOIN team_leader_photos TLP
          	ON TL.team_leader_id = TLP.team_leader_id        
        WHERE
        		AL.activity_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#Trim( Url.activity )#" />

The dates are coming from the table activity_dates. And I would like to have my output like this:

09/09, 10/09, 15/09, 20/09

Thank you in advance foar looking at it

Hi Rudy, that was indeed the way to go.

This is how I solved it:


DATE_FORMAT( activity_date, '%d/%m') AS newDate

and than after the query


<cfset dateList = valueList ( getDetails.newDate, ", " )> 

and it is working great. Thanks for the input.

I don’t think you can have spaces in a list. You should try using Arrays instead.

you think arrays will allow spaces?? (:

Yes, it works. Try this code:

[FONT=Courier New]<cfset a = ArrayNew(1)>

<cfset a[1] = “1”>
<cfset a[2] = " ">
<cfset a[3] = “a”>

<ul>
<cfloop from=“1” to=“#ArrayLen(a)#” index=“i”>
<cfoutput><li>|#a[i]#| - #ASC(a[i])#</li></cfoutput>
</cfloop>[/FONT]

The valuelist as described above gave me the desired result.