Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old November 20th, 2008, 07:54 PM
Authorized User
 
Join Date: May 2007
Location: , , .
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default convert time to minutes

Does anyone know if XSLT 2.0 supports converting time to minutes?

where

<dateTime>2008-11-21T01:05:00-06:00</dateTime>

would return 65 minutes
  #2 (permalink)  
Old November 20th, 2008, 11:44 PM
Friend of Wrox
Points: 1,306, Level: 14
Points: 1,306, Level: 14 Points: 1,306, Level: 14 Points: 1,306, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2008
Location: Pondicherry, India
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Default

Try this:
minutes-from-dateTime()

------
Rummy
  #3 (permalink)  
Old November 21st, 2008, 01:14 AM
Friend of Wrox
Points: 1,306, Level: 14
Points: 1,306, Level: 14 Points: 1,306, Level: 14 Points: 1,306, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2008
Location: Pondicherry, India
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Default

Sorry Try this:
<xsl:template match="dateTime">
        <xsl:variable name="a1" select="."/>
        <xsl:variable name="a2">
            <xsl:value-of select="hours-from-dateTime($a1) * 60 + minutes-from-dateTime($a1)"></xsl:value-of>
        </xsl:variable>
        <xsl:value-of select="$a2"></xsl:value-of>
    </xsl:template>

------
Rummy
  #4 (permalink)  
Old November 21st, 2008, 04:12 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Something like this, assuming dateTime is typed by the schema as xs:dateTime:

(dateTime - xs:dateTime(xs:date(dateTime))) div xs:dayTimeDuration('PT1M')

If it's not schema-aware, do xs:dateTime(dateTime) to convert the untyped value to a dateTime first.

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert time field to number jobalistic Access 17 February 22nd, 2013 12:40 PM
[Resolved] Convert Time to Integer snufse ASP.NET 2.0 Basics 1 October 7th, 2008 11:44 AM
Convert String To Time GailCG ASP.NET 2.0 Basics 1 January 9th, 2008 01:09 AM
Calculate time (minutes) between two times rtr1900 Classic ASP Basics 18 January 2nd, 2008 03:06 PM
Time Convert in ASP ;Please help blueguy Classic ASP Components 6 August 5th, 2004 02:49 AM





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