Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 12th, 2009, 02:14 PM
Registered User
 
Join Date: Nov 2009
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default Need Date Format in XSLT

Hi ,

I get the date in the below format in one element :
2009-06-17T00:00:00

and need to convert and format the same in to 06172009.

I need to do that in XSLT . can some body please suggest me some thing.

Any help is appreciated.

Pavan
 
Old November 12th, 2009, 02:26 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Well with XSLT/XPath 2.0 you could create an xs:dateTime(foo) and then use methods like format-dateTime http://www.w3.org/TR/xslt20/#function-format-dateTime.
Code:
  <xsl:template match="foo">
    <xsl:value-of select="format-dateTime(xs:dateTime(.), '[M01][D01][Y0001]')"/>
  </xsl:template>
With XSLT/XPath 1.0 you will need to use string functions e.g.
concat(substring(foo, 6, 2), substring(foo, 9, 2), substring(foo, 1, 4))
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
The Following User Says Thank You to Martin Honnen For This Useful Post:
garinapavan (November 12th, 2009)
 
Old November 12th, 2009, 03:49 PM
Registered User
 
Join Date: Nov 2009
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks Martin





Similar Threads
Thread Thread Starter Forum Replies Last Post
date format differs, need to force format somehow patricolsson ASP.NET 2.0 Basics 1 December 3rd, 2009 12:53 AM
How to format date using XSLT navi25584 XSLT 3 September 2nd, 2008 07:00 AM
Convert British format date to American format? fyr PHP How-To 0 December 19th, 2007 03:17 PM
XSLT - Convert the date in different format haixia XSLT 1 August 25th, 2006 11:51 AM
Date format in XSLT rk2203 XSLT 2 November 29th, 2005 04:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.