Copied to clipboard

Flag this post as spam?

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


  • Lachlann 343 posts 625 karma points
    Dec 10, 2010 @ 00:07
    Lachlann
    0

    uComponents mutliple date logic help

    Hey Its late and this one is escaping me!

    I am using the multiple date picker for an events calander I am trying to  return only events with start dates later than today

    to get at the multiple dates I have split the comma seperated values

    <xsl:variable name="dates" select="umbraco.library:Split(./startDates, ',')"/>

    this returns:

    <values>
       <value>2010-12-21 13:00</value>

       <value>2011-01-10 13:00</value>

       <value>2011-02-03 13:00</value>

       <value>2011-02-28 13:00</value>
    </values>

    I am trying to return a count of those dates which are later than or equal to todays date using:

    <xsl:value-of select="count($dates/descendant::*[name()='value' and umbraco.library:DateGreaterThanOrEqualToday(./value)])"/>

    This works when i substitute the ./value with '2010-12-21 13:00' but when i try './value' or '.' i get

    System.FormatException: String was not recognized as a valid DateTime.
    Any help at all would be really great!

     

    thanks

     

    L


  • Lee Kelleher 3945 posts 15163 karma points MVP 10x admin c-trib
    Dec 10, 2010 @ 00:19
    Lee Kelleher
    1

    Hi Lachlann,

    Try this XPath expression instead:

    <xsl:value-of select="count($dates/value[umbraco.library:DateGreaterThanOrEqualToday(.)])" />

    I can't remember if it should be "$dates/values/value" or just "$dates/value" ... if the example above doesn't work, try adding "values" in there.

    Cheers, Lee

  • Lachlann 343 posts 625 karma points
    Dec 10, 2010 @ 09:57
    Lachlann
    0

    Thanks Lee,

     

    This nearly works (and makes more sense than what I was attempting) but still isnt giving the result I would expect from the values I have. I will work on it tonight and see if  i can get it working.

     

    L

  • Lachlann 343 posts 625 karma points
    Dec 10, 2010 @ 20:14
    Lachlann
    0

    Hey Lee,

    If I use

    <xsl:value-of select="count($dates/value[umbraco.library:DateGreaterThanOrEqualToday(.)])"/>

    I get the System.FormatException: String was not recognized as a valid DateTime.

    If i try using 

    <xsl:value-of select="count($dates/values/value[umbraco.library:DateGreaterThanOrEqualToday(.)])"/>

    It just returns a count of 0 which isnt right

    but if I just count the number of values in the mutlidate property like this.

    <xsl:value-of select="count($dates/value)"/>

    It returns what i would expect (i.e. a count of the number of dates). So it makes sense to me that I should just be able to add the [] statement to filter out only those which habe a date greater than or equal to today.

    I just dont get this system exception.

    L

  • Lachlann 343 posts 625 karma points
    Dec 11, 2010 @ 12:22
    Lachlann
    0

    OKAY! I fieed the issue sort of. The problem was due to there being an event with no date values.

    I tried to do this:

    <xsl:value-of select="count($dates/value[(.!='') and (umbraco.library:DateGreaterThanOrEqualToday(.))])"/>

    but this wouldnt work (any ideas?) in the end i set the event date as a mandatory field which it should have been anyway.

    So hopefully that will mitigate the problem.

    Thanks for your help Lee.

     

    L

  • Lachlann 343 posts 625 karma points
    Dec 11, 2010 @ 12:25
    Lachlann
    1

    UPDATE, atually this does work:

    <xsl:value-of select="count($dates/value[(.!='') and umbraco.library:DateGreaterThanOrEqualToday(.)])"/>

    I swear it didnt before! So by making sure there is a value in the date field the umbraco library function doesnt throw a fit.

    Could some one please mark this as the answer?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies