xsl-list
[Top] [All Lists]

RE: Problem with Variables

2004-02-02 08:51:04

I am writing a stylesheet which makes a conversion of a date. 
ie: 1.3.2003 should become 2003.03.01

You can do this in one line:

<xsl:value-of select="
    concat(
    substring-after(substring-after($date,'.'),'.')
    ,'.',
    format-number(substring-before(substring-after($date,'.'),'.'),'00')
    ,'.',
    format-number(substring-before($date,'.'),'00')
    )"/>

The only bit I think you wont already know here is format-number(),
which in this case allows you to pad with zeros to get at least 2 digits

cheers
andrew 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>