I have two dates in the following format:
1) <xsl:value-of select="ddwrt:FormatDateTime(string(@Status_x0020_Date) ,1033 ,'yyyy-MM-dd ')" />
2)<xsl:value-of select="ddwrt:FormatDateTime(string(../../../Strategic_Items_Daily_Status/Rows/Row/@Status_x0020_for_x0020_Last_x002) ,1033 ,'yyyy-MM-dd ')" />
I am using SharePoint Designer to create a condition to compare these values. Status Date should be greater than or equal to Status for Last Month.
I started with checking if Status Date is greater than or eqal to Status for Last Month but I think SPD gets the "translate" wrong. Any ideas?
[@Item_x0020_ID = $dvt_ParentRow/@ID and
number(translate(substring-before(../../../../../../../..开发者_开发问答/../Rows/Row/@Status_x0020_Date,'T'),'-',''))
<= number(translate(substring-before($Today,'T'),'-',''))]
The output of the dates on the page are like 2010-09-01.
Thanks in advance.
Edit: the problem is that I don't get any output, only if I have status date is not equal to status for last month.
You don't need the number function, if the two textual values are both numbers it'll just compare them as if they were.
I suspect your problem may be your use of <=
as a comparator; you'll need to escape the <
with <
instead, and use <=
.
As far as doing a date difference goes, I use this template (Xslt 1.0):
<xsl:template name="calcdays">
<xsl:param name="date" />
<xsl:variable name="year" select="substring($date,1,4)" />
<xsl:variable name="month" select="substring($date,6,2)" />
<xsl:variable name="day" select="substring($date,9,2)" />
<xsl:value-of select="(($year - 1970) * 365) + floor(($year - 1969) div 4) + substring('000,031,059,090,120,151,181,212,243,273,304,334,365',($month * 4) - 3,3) + ($day - 1) + (1 - floor((($year mod 4) + 2) div 3))*floor(($month + 17) div 20)" />
</xsl:template>
</xsl:stylesheet>
to determine the number of days since 1st Jan 1970, assuming the parameter passed in is in the form yyyy-mm-dd
Any other form, you can tweak the substrings.
Call this template with the date strings and pass the results into variables, and you can do a straight comparison on $later - $earlier <= 30
.
精彩评论