[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Date Difference

Subject: RE: Date Difference
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 19 Dec 2005 17:31:44 -0500
isdategreater
Tom,

The cheap easy way to do it doesn't involve the "dateness" of your dates; it merely involves rearranging your dates into a form in which they can be meaningfully compared with each other.

If you can write the code that will create, from each of these,

12/20/2005 => 20051220
1/1/2006   => 20060101
3/15/1995  => 19950315

you see it becomes merely a numeric comparison.

Whether you can do this with the substring() function depends on whether your values include zeroes. (That is, no 1/1/2006 since 200611 isn't useful.) Operations using substring-before() and substring-after(), taking the '/' as the delimiting substring -- or the saxon or XPath 2.0 tokenize() function -- would be more dependable.

If you want your dates to have "dateness", XPath 2.0 is the way to go, and Mike H has shown the way forward. But your format is wrong for that conversion too.

Cheers,
Wendell

At 04:56 PM 12/19/2005, you wrote:
I wrote this:

      <xsl:function name="sgfr:IsDateGreater">
            <xsl:param name="stringDate1"/>
            <xsl:param name="stringDate2"/>
            <xsl:variable name="tokenizedDate1"
select="tokenize($stringDate1, '/')"/>
            <xsl:variable name="monthPart1"
select="subsequence(($tokenizedDate1), 1, 1)"/>
            <xsl:variable name="datePart1"
select="subsequence(($tokenizedDate1), 2, 1)"/>
            <xsl:variable name="yearPart1"
select="subsequence(($tokenizedDate1), 3, 1)"/>
            <xsl:variable name="tokenizedDate2"
select="tokenize($stringDate2, '/')"/>
            <xsl:variable name="monthPart2"
select="subsequence(($tokenizedDate2), 1, 1)"/>
            <xsl:variable name="datePart2"
select="subsequence(($tokenizedDate2), 2, 1)"/>
            <xsl:variable name="yearPart2"
select="subsequence(($tokenizedDate2), 3, 1)"/>
            <xsl:choose>
                  <xsl:when test="yearPart1>yearPart2"><xsl:value-of
select="true"/></xsl:when>
                  <xsl:when test="yearPart1=yearPart2">
                        <xsl:choose>
                              <xsl:when test="monthPart1>monthPart2">
                                    <xsl:value-of select="true"/>
                              </xsl:when>
                              <xsl:when test="monthPart1=monthPart2">
                                    <xsl:choose>
                                          <xsl:when
test="datePart1>datePart2"><xsl:value-of select="true"/></xsl:when>
                                          <xsl:otherwise><xsl:value-of
select="false"/></xsl:otherwise>
                                    </xsl:choose>
                              </xsl:when>
                              <xsl:otherwise><xsl:value-of
select="false"/></xsl:otherwise>
                        </xsl:choose>
                  </xsl:when>
                  <xsl:otherwise><xsl:value-of
select="false"/></xsl:otherwise>
            </xsl:choose>
      </xsl:function>

Will this work?
Or am I totally missing the point?

Regards,


Tom Maciejewski



************************************************************************* This message and any attachments (the "message") are confidential and intended solely for the addressees. Any unauthorised use or dissemination is prohibited. E-mails are susceptible to alteration. Neither SOCIETE GENERALE nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified.

*************************************************************************


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.