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 December 18th, 2007, 12:44 PM
Authorized User
 
Join Date: Jun 2007
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default using format-time to extract hour

I am trying to extract the hour from an ISO timestamp, but am unable to get the following to work.

<xsl:variable name="d" select="2008-01-01T11:00:00-06:00" as="xs:dateTime"/>

<xsl:value-of select="format-time($d,'[h]')"/>
 
Old December 18th, 2007, 12:50 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

This is not a valid XPath expression:

2008-01-01T11:00:00-06:00

You want

xs:dateTime('2008-01-01T11:00:00-06:00')

By the way, it's usually much easier to tell people what they have done wrong if they quote the error message. In this case it only took a few seconds to find the error in your code, but why leave out the message that explains it?

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old December 18th, 2007, 12:57 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

That and the fact that if you use xs:dateTime then you need to use format-dateTime(), not format-time().

/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Hour by Hour Matrix Report Ed_Conde BOOK: Professional SQL Server 2005 Reporting Services ISBN: 0-7645-8497-9 0 August 12th, 2008 02:51 PM
Extract data from Word Document(RTF format) PaulJH Access 2 September 19th, 2006 07:52 AM
Time format MDM ASP.NET 2.0 Professional 2 July 12th, 2006 10:37 AM
Using xs:time to generate time in desired format krayan001 XSLT 0 June 27th, 2005 04:28 PM
How to show 24 Hour Time? Edward King Oracle 1 July 31st, 2004 04:44 AM





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