Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • AlexR 39 posts 61 karma points
    Sep 02, 2010 @ 12:27
    AlexR
    0

    How to compare dates

    I try to compare two dates and always get false.

     <xsl:variable name="now" select="Exslt.ExsltDatesAndTimes:datetime()" />

    <xsl:value-of select="string(data[@alias='contentDate'])" />
    return 2010-11-18T11:41:00

    <xsl:value-of select="string($now)" />
    return 2010-09-02T17:18:31

    <xsl:value-of select="string(data[@alias='contentDate']) &lt; string($now)" />
    return false

    <xsl:value-of select="string(data[@alias='contentDate']) > string($now)" />
    return false

    Why the last is false?

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Sep 02, 2010 @ 12:44
    Chriztian Steinmeier
    1

    Hi AlexR,

    Unfortunately you can't compare strings this way in XSLT - there's a couple of comparison functions available in the umbraco.library namespace, e.g.:

    <xsl:value-of select="umbraco.library:DateGreaterThanOrEqualToday(data[@alias = 'contaentDate'])" />

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft