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:
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']) > 0]">
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.)
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
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']) > 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() < 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?
Should I report this as a bug, or could it be something to do with SQL2005?
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
I've just been told that this is a known issue.... is that correct?
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
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
is working on a reply...