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.
but if I just count the number of values in the mutlidate property like this.
<xsl:value-ofselect="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.
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
Hi Lachlann,
Try this XPath expression instead:
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
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
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
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
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?
is working on a reply...