Copied to clipboard

Flag this post as spam?

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


  • Dan 1288 posts 3921 karma points c-trib
    Nov 09, 2010 @ 18:35
    Dan
    0

    Selecting all nodes where date greater than value

    Hi,

    I have a calendar of events.  I'm using XSLT to count all events which occur on or after a particular date, but it always returns zero when I do this:

    <xsl:variable name="eventsToday" select="count($currentPage/descendant::*
     [@isDoc and (name()='Production' or name()='EventItem') and 
    (umbraco.library:FormatDateTime(./startDateTime, 'dd/MM/yyyy') &gt;= 
    '02/10/2010')])" />

    However, when I change the operator from &gt;= to just = it does pick up the event on this particular day:

    <xsl:variable name="eventsToday" select="count($currentPage/descendant::*
     [@isDoc and (name()='Production' or name()='EventItem') and 
    (umbraco.library:FormatDateTime(./startDateTime, 'dd/MM/yyyy') = 
    '02/10/2010')])" />

    I've tried using umbraco.library:FormatDateTime on the hard-coded date, but it makes no difference - it just seems that dates can't be subject to 'less than' or 'greater than' operators in XSLT.  Is this true?

    Can anyone see how to rectify this?

    Thanks

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Nov 09, 2010 @ 18:49
    Sebastiaan Janssen
    1

    Format the date as 20101002 (maybe you'll have to convert it to a number in XSLT) and then you can do greater or less just fine! :)

  • Powellze 38 posts 73 karma points
    Nov 10, 2010 @ 11:52
    Powellze
    4

    An old XSLT I have which might serve as a good example for the Umbraco Library GreaterThan:

    <xsl:for-each select="$currentPage/child::node/node/node [@nodeTypeAlias = 'BS_EventItem' and 
    umbraco.library:DateGreaterThanOrEqualToday(data[@alias='eventDate']) != true]"
    >
    </xsl:for-each>

    Here is the umbraco library which lists all the date greater than etc....

    http://our.umbraco.org/wiki/reference/umbracolibrary

  • Dan 1288 posts 3921 karma points c-trib
    Nov 10, 2010 @ 12:52
    Dan
    0

    Thanks Sebastian/Powellze.  I've ended up using the 'DateGreaterThanOrEqual' XSLT extension as it feels a little more solid than formatting dates as numbers (which I've no doubt works too though!)  Somehow I'd missed those extensions in the documentation.

Please Sign in or register to post replies

Write your reply to:

Draft