Copied to clipboard

Flag this post as spam?

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


  • Tizer 170 posts 201 karma points
    Sep 30, 2010 @ 12:12
    Tizer
    0

    Bad code or umbraco FormatDateTime bug - SQL2005?

    OK - I have a problem which Iam not sure about - I thought it was a node problem previously - but now I am not sure.

    I am trying to sort by date (using Datepicker) - showing only the first article based on the latest date. These are the date fields (using the  of the 2 nodes in question in the umbraco.config:

    <data alias="date">2010-09-27T00:00:00</data>
    <data alias="date">2010-08-30T00:00:00</data>

    The problem is that the 2nd node displays before the first (all other nodes of earlier dates display fine) - but if I change the 2nd node to a value equal or below 27 (the day - so <data alias="date">2010-08-27T00:00:00</data>) then it displays correctly - or vica versa, if I change the 1st node to a value greater or equal than 30 (<data alias="date">2010-0930T00:00:00</data>) then it displays in the correct order.

    This is the server config: Windows 2008 Server Standard, SP2 x86, SQL 2005.

    I have the same site running on a a SQL 2008 server and all seems to work fine.

    This is the part of my XSLT code in question:

    _ _ _ _ _ _ _ _ _ 

    <xsl:template match="/">

    <xsl:for-each select="$currentPage/child::node[@nodeTypeAlias = 'Category' and count(descendant::node[@nodeTypeAlias = 'Article']) &gt; 0]">

    <xsl:for-each select="current()/descendant::node[@nodeTypeAlias = 'Article']">

    <xsl:sort select="umbraco.library:FormatDateTime(data[@alias = 'date'], 'yyyymmdd')" order="descending"/>
       
    <xsl:if test="position() &lt; 2">
               
    <!-- MY DATA -->
               
    </xsl:if>

    </xsl:for-each>

    </xsl:for-each>

    </xsl:template>

    _ _ _ _ _ _ _ _ _ 

    So is this bad code on my part, or an umbraco FormatDateBug bug on SQL 2005?

     

  • Tizer 170 posts 201 karma points
    Oct 01, 2010 @ 01:11
    Tizer
    0

    Should I report this as a bug, or could it be something to do with SQL2005?

  • Tizer 170 posts 201 karma points
    Oct 01, 2010 @ 07:32
    Tizer
    0

    nm... this has to be down to my bad code I feel - I have no other answer

    My code seems to be displaying the highest day (last 2 numbers) and ignoring the other numbers.

    Descending - I should have this numbers from the code below

    20100927
    20100830

    
    
    

    using 20101001 (todays date, both of the numbers above override this - even though it us a larger number.

    Is there something blatent I am missing?

    What I want to do is display the latest article based on the date value

  • Tizer 170 posts 201 karma points
    Oct 02, 2010 @ 03:34
    Tizer
    0

    I've just been told that this is a known issue.... is that correct?

  • Jonas Eriksson 930 posts 1825 karma points
    Oct 03, 2010 @ 05:29
    Jonas Eriksson
    0

    Hi Tye!

    I think you should be fine with <xsl:sort select="umbraco.library:FormatDateTime(data[@alias = 'date'], 'yyyymmdd')" order="descending"/> but ... mm gives you the minute, use MM instead. yyyyMMdd, ref http://www.csharp-examples.net/string-format-datetime/

    (Crazy one if you ask me, they (MS) should better use all uppercase for dates and all lowercase for time.)

    Regards,

    Jonas

  • Tizer 170 posts 201 karma points
    Oct 04, 2010 @ 05:49
    Tizer
    0

    Jonas - you star - I'm not sure how many times I looked over that code and missed that... I was sure it was correct - so just skipped over it Thank you

Please Sign in or register to post replies

Write your reply to:

Draft