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?

  • AlexR 39 posts 61 karma points
    Sep 03, 2010 @ 04:59
    AlexR
    0

    How to compare dates in xslt? Anybody can answer?

  • Bo Kingo Damgaard 157 posts 456 karma points
    Sep 03, 2010 @ 08:49
    Bo Kingo Damgaard
    0

    You could use

    <xsl:value-of select="umbraco.library:DateGreaterThan('2010-09-02T17:18:31','2010-11-18T11:41:00')"/>

    returns false

     


    <xsl:value-of select="umbraco.library:DateGreaterThan('2010-11-18T11:41:00','2010-09-02T17:18:31')"/>

    returns true

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 03, 2010 @ 08:49
    Dirk De Grave
    0

    There's a few static functions available in the umbraco.library class for comparing dates: http://our.umbraco.org/wiki/reference/umbracolibrary and http://umbraco.org/apiDocs/html/AllMembers_T_umbraco_library.htm

     

    Hope this helps.

    Regards,

    /Dirk

Please Sign in or register to post replies

Write your reply to:

Draft