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 20th, 2008, 07:54 PM
Authorized User
Join Date: May 2007
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?



would return 65 minutes
Old November 20th, 2008, 11:44 PM
Friend of Wrox
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts

Try this:

Old November 21st, 2008, 01:14 AM
Friend of Wrox
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts

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:value-of select="$a2"></xsl:value-of>

Old November 21st, 2008, 04:12 AM
mhkay's Avatar
Wrox Author
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

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
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.