Copied to clipboard

Flag this post as spam?

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


  • Darryl Godden 145 posts 197 karma points
    May 10, 2010 @ 13:51
    Darryl Godden
    0

    FormatException using DateGreaterThanOrEqualToday

    Hi all,

    I have this test in my xsl:if

       <xsl:if test="umbraco.library:DateGreaterThanOrEqualToday(data [@alias = 'meetingDate'])">

    However this is throwing an error

    System.FormatException: String was not recognized as a valid DateTime. 
    at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) 
    at umbraco.library.DateGreaterThanOrEqualToday(String firstDate)

    The meetingDate is a date picker with time on a media content. I have checked the 10+ meetings in the system and they all have a value.

    Thanks

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    May 10, 2010 @ 14:00
    Dirk De Grave
    0

    Darryl,

    Looks like you've forgot to enter the xslt context, either use

    <xsl:if test="umbraco.library:DateGreaterThanOrEqualToday(./data [@alias = 'meetingDate'])">

    if you're inside a loop or

    <xsl:if test="umbraco.library:DateGreaterThanOrEqualToday($currentPage/data [@alias = 'meetingDate'])">

    if you're getting the property from the current page being requested

     

    Hope this helps.

    Regards,

    /Dirk

  • Darryl Godden 145 posts 197 karma points
    May 10, 2010 @ 14:03
    Darryl Godden
    0

    Still coming up with the same error..

    Just to expand, it is sat inside a loop:

    <xsl:for-each select="umbraco.library:GetMedia(1436, 'true')/node">
        <xsl:variable name="agendaFile" select="data [@alias = 'meetingAgenda']" />
        <xsl:variable name="minutesFile" select="data [@alias = 'meetingMinutes']" />
        <xsl:variable name="author" select="umbraco.library:GetMember(data [@alias = 'meetingAddedBy'])" />
    
        <xsl:if test="umbraco.library:DateGreaterThanOrEqualToday(./data [@alias = 'meetingDate'])">
            <span class="dataRow">
                <div class="reportDate">
                    <xsl:value-of select="umbraco.library:FormatDateTime(data [@alias = 'meetingDate'],'dd/MM/yyyy')"/>
                </div>
                <div class="reportTitle">
                    <div class="eventTitle"><xsl:value-of select="data [@alias = 'meetingTitle']"/></div>
                </div>
                <div class="reportSubTitle">
                    <xsl:value-of select="data [@alias = 'meetingLocation']"/>
                    <br />
                    <xsl:value-of select="$author/data [@alias = 'first_name']" />&nbsp;<xsl:value-of select="$author/data [@alias = 'last_name']" /> - <xsl:value-of select="umbraco.library:GetXmlNodeById($author/data [@alias = 'arena_member'])/@nodeName" />
                </div>
                <br style="clear:both;" />
            </span>
        </xsl:if>
    </xsl:for-each>

    thanks

  • Darryl Godden 145 posts 197 karma points
    May 10, 2010 @ 14:21
    Darryl Godden
    0

    This is a weird one, it is outputting the meeting title, location etc but not the date, we have commented out the if test and we get no meeting date returned, any ideas why this could be?

    Thanks,

  • Darryl Godden 145 posts 197 karma points
    May 10, 2010 @ 14:30
    Darryl Godden
    0

    Maybe a bug found here.

    'meetingDate' used to be called 'meetingDateTime', it was changed to reflect that we don't use the time portion in output or selection. It appears that the new name for the property did not update when the name was changed. I have gone in and manually updated each date and the dates now appear.

  • Darryl Godden 145 posts 197 karma points
    May 10, 2010 @ 14:31
    Darryl Godden
    0

    As always, thanks for your help Dirk.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    May 10, 2010 @ 15:04
    Dirk De Grave
    0

    Good to know, if you change a few property names, always remember to publish the entire site, so the cached xml gets refreshed and gets populated with the correct property aliases

     

    Cheers,

    /Dirk

  • Darryl Godden 145 posts 197 karma points
    May 10, 2010 @ 15:29
    Darryl Godden
    0

    I'll mark yours as the answer, especially as I cannot answer my own answer ;)

  • kentiler 76 posts 69 karma points
    Oct 25, 2010 @ 16:49
    kentiler
    0

    I'm getting the same thing.  We haven't changed any property names, and it was working previously.  We are using umbraco v 4.0.3 (Assembly version: 1.0.3625.27276).

    The line where we get the error is:

    <xsl:variable name="upcomingEvents" select="$currentPage/..//node[@nodeTypeAlias='eventItem'][umbraco.library:DateGreaterThanOrEqualToday(data[@alias='Date'])]"/>


    The exact error is:

    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.DateGreaterThanOrEqualToday(String firstDate)

    I've search the forums, and tried adding a FormatDateTime function, but I'm not having any success at getting over this hurdle.

    Any suggestions would be appreciated!

    Thank you!

    --Kent

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Oct 25, 2010 @ 20:43
    Chriztian Steinmeier
    0

     

    Hi Kent,

    The error message is a pretty good indication of the presence of one or more 'Date' properties with bad data - try the following lines and see what you get:

    <!-- Grab the eventItem nodes for easier access afterwards: -->
    <xsl:variable name="eventItems" select="$currentPage/..//node[@nodeTypeAlias = 'eventItem']" />
    
    <!-- Count them all: -->
    <p><xsl:value-of select="count($eventItems)" /></p>
    
    <!-- Count the number of eventItems with a Date property: -->
    <p><xsl:value-of select="count($eventItems[data[@alias = 'Date']])" /></p>
    
    <!-- Count the number of eventItems with a non-empty Date property: -->
    <p><xsl:value-of select="count($eventItems[normalize-space(data[@alias = 'Date'])])" /></p>
    
    Are you getting the same number of nodes in all cases?

    /Chriztian

     

Please Sign in or register to post replies

Write your reply to:

Draft