System.FormatException: String was not recognized as a valid DateTime. at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) at umbraco.library.DateGreaterThanOrEqual(String firstDate, String secondDate)
why function DateGreaterThanOrEqual(String firstDate, String secondDate) not get my datepicker value, besides it is not giving error when used "sdate" variable
How many documents of the type Test1 do you have in the site?
The thing is that $fdate actually a nodeset of all the CompEnd properties of all Test1 documents in the Umbraco solution - so that might be the problem (because a nodeset is sent to the function).
The reason you get a seemingly valid value with value-of, is because the value-of instruction will only output the first node, if passed a nodeset.
So I think you need to specify the exact node you want to do the comparison with...
I have used only one time "Test1" document type in my hierarchy. So in that case there is only one property named "CompEnd" in hierarchy. I am still stuck by this problem. So if you have any other solution/idea/suggestion regarding this problem, Please reply ASAP.
Tricky stuff - could you try the DateGreaterThanOrEqualToday(String date) function? Just to see if that throws errors as well?
I'm curious if this could be Locale related somehow... which language is the machine set to? Have you assigned a hostname and language to the tree containing the CompEnd property?
I have used DateGreaterThanOrEqualToday(String date) function and passed "CompEnd" property value to it, but it throws the same error. Don't know what's happen with it? Do you know solution of this type error? Yes I have assigned hostname and language to the tree.
I experiencedthe sameproblem.Got an error messagewhen I compared datepicerdate and todays date.I justcheckthe "Skiptesting(ignoreerrors)" in the xsl editor andsaved thefile,and it worked on the site.
By checkingif the datepicer date isblank or not it works, no error message in the xsl editor.
Parsing Error In umbraco.library.DateGreaterThanOrEqual(String firstDate, String secondDate)
I get error when comare tow dates using function DateGreaterThanOrEqual(String firstDate, String secondDate)
when I compare using current date its working properly, but when I compare current date with datepicter date , It gives error
my code is:-
<xsl:variable name="node" select="$currentPage/ancestor-or-self::node/descendant-or-self::node[@nodeTypeAlias = 'Test1']" />
<xsl:variable name="fdate" select="$node/data[@alias='CompEnd']"/>
<xsl:variable name="sdate" select="umbraco.library:CurrentDate()"/>
<xsl:value-of select="umbraco.library:DateGreaterThanOrEqual( $fdate, $sdate)" disable-output-escaping="yes"/>
Error occured
System.FormatException: String was not recognized as a valid DateTime.
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
at umbraco.library.DateGreaterThanOrEqual(String firstDate, String secondDate)
Thanks,
Hi Ankita,
Is it possible that "$node/data[@alias='CompEnd']" doesn't contain a date? Try outputting it to see what's in there.
Cheers, Lee.
Hi Lee,
I have checked the value that comes from
<xsl:value-of select="$fdate"/>
<br/>
<xsl:value-of select="$sdate"/>
is in format
2012-08-13T02:32:00
2012-08-30T08:43:50
But when we compare currentdate this does not give any error , It works properly.
Is there anyone who can solve my problem.
why function DateGreaterThanOrEqual(String firstDate, String secondDate) not get my datepicker value, besides it is not giving error when used "sdate" variable
<xsl:variable name="sdate" select="umbraco.library:CurrentDate()"/>
In sdate it get current date
I have checked the value that comes from my datapicker property and current date is:-
<xsl:value-of select="$datepicker"/> <xsl:value-of select="$currentdate"/>
is in format
2012-08-13T02:32:00
2012-08-30T08:43:50
Please tell me what's a silly mistake that I am doing .
Please help me ,I got stuck by this error
Any reply would be appreciable,
thanks in advance
Hi Ankita,
How many documents of the type Test1 do you have in the site?
The thing is that $fdate actually a nodeset of all the CompEnd properties of all Test1 documents in the Umbraco solution - so that might be the problem (because a nodeset is sent to the function).
The reason you get a seemingly valid value with value-of, is because the value-of instruction will only output the first node, if passed a nodeset.
So I think you need to specify the exact node you want to do the comparison with...
/Chriztian
Hi Chriztian,
I have used only one time "Test1" document type in my hierarchy. So in that case there is only one property named "CompEnd" in hierarchy. I am still stuck by this problem. So if you have any other solution/idea/suggestion regarding this problem, Please reply ASAP.
thanks,
Bhuvneshwari.
Okay,
Tricky stuff - could you try the DateGreaterThanOrEqualToday(String date) function? Just to see if that throws errors as well?
I'm curious if this could be Locale related somehow... which language is the machine set to? Have you assigned a hostname and language to the tree containing the CompEnd property?
/Chriztian
Hi Chriztian,
I have used DateGreaterThanOrEqualToday(String date) function and passed "CompEnd" property value to it, but it throws the same error. Don't know what's happen with it? Do you know solution of this type error? Yes I have assigned hostname and language to the tree.
Thanks for your reply
Which language have you set?
Could you post the entire XSLT file? (Or if it's large, put it on http://gist.github.com and link to it).
/Chriztian
Here is my Xslt file:-
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:datetime="http://exslt.org/dates-and-times"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:myfunctionlib="urn:myfunctionlib"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets umbraco.library myfunctionlib ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:variable name="node" select="$currentPage/ancestor-or-self::node/descendant-or-self::node[@nodeTypeAlias = 'Test1']" />
<xsl:variable name="fdate" select="$node/data[@alias='CompEnd']"/>
<xsl:variable name="sdate" select="umbraco.library:CurrentDate()"/>
<!--
<xsl:value-of select="umbraco.library:DateGreaterThanOrEqual( $sdate, $fdate)"/>
<xsl:value-of select="$fdate"/><br/>
<xsl:value-of select="$sdate"/>
<xsl:value-of select="umbraco.library:FormatDateTime($node/data[@alias='CompEnd'], 'ddd, dd MMM yyyy hh:mm:ss')"/>
<br/>
<xsl:value-of select="umbraco.library:FormatDateTime(umbraco.library:CurrentDate(), 'ddd, dd MMM yyyy hh:mm:ss')"/>
<br/>
<xsl:value-of select="Exslt.ExsltDatesAndTimes:formatdate( $fdate, 'g')"/>
<br/>
<xsl:value-of select="Exslt.ExsltDatesAndTimes:formatdate( $sdate, 'g')"/>
<xsl:value-of select="umbraco.library:DateGreaterThanOrEqual($b2, $b1)"/>
-->
<xsl:variable name="b1" select="umbraco.library:FormatDateTime($node/data[@alias='CompEnd'], 'ddd, dd MMM yyyy hh:mm:ss')"/>
<xsl:variable name="b2" select="umbraco.library:FormatDateTime(umbraco.library:CurrentDate(), 'ddd, dd MMM yyyy hh:mm:ss')"/>
<xsl:choose>
<xsl:when test="$sdate <= $fdate">
<xsl:if test="$sdate <= $fdate">
<div class="comp_end">
<xsl:variable name="node1" select="$currentPage/ancestor-or-self::node/descendant-or-self::node[@nodeTypeAlias = 'ContestEnd'] "/>
<div class="comp_question"><xsl:value-of select="$node1/data[@alias = 'EndContestTitle']" disable-output-escaping="yes" /></div>
</div> <!-- End comp_end -->
</xsl:if>
</xsl:when>
<xsl:otherwise>
<div style="comp_start">
<xsl:variable name="node2" select="$currentPage/ancestor::node[@nodeTypeAlias = 'test']" />
<div class="comp_cta"><a href="#">Enter Competition Here</a></div>
</div> <!-- End comp_start -->
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
is working on a reply...