Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xsl inString? 1

Status
Not open for further replies.

rhull

Programmer
May 23, 2001
46
US
I get data back unformatted and need to make the date readable

<xsl:for-each select=&quot;roa/events/evregular/event&quot;>
<table border=&quot;0&quot; cellpadding=&quot;0&quot;>

<TR>xsl:value-of select=&quot;date&quot;/></TR>

</table>
</xsl:for-each>

The result is
19920114

is there a inString way to split it up?

Thanks!
-Ryan
 
Hi Ryan,
You can use the string function substring to extract the date as you want and format it accordingly. For example, to get the day, I always set up a variable as with param below:

<xsl:param name=&quot;new_date&quot; select=&quot;date&quot;/>

Then extract date as you want it to appear:
<!--Get day-->
<xsl:value-of select=&quot;substring($new_date,7,2)&quot;/>
<!--Separate with /-->
<text>/</text>
<!--Get month-->
<xsl:value-of select=&quot;substring($new_date,5,2)&quot;/>
<text>/</text>
<!--Get year-->
<xsl:value-of select=&quot;substring($new_date,1,4)&quot;/>

Quickly thrown together, but it should give you a date like 11/23/1999. If you want a string date like January 1, 1999, you would have to set up a <xsl:choose> & <xsl:when> statement within the same scope to test for the number of the month to output the string month as January, February, etc.

I hope this helps.
--Donna

 
I get an error every time i try to put the code in to create a variable, I even tried to just put a substring in front of the data

<xsl:value-of select=&quot;substring(filedate,1,4)&quot;/>

Do i need a special parser that recognizes what substring means?


Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top