Question

I haven't worked on XSL.

Scenario: We have a list which has a column called expiry. We want to display only those records which have expiry date greater than or equal to today's date.

Trials: After n number if trials and googling have found out how to set a XSL variable today's date

<xsl:variable name="curDt" select="ddwrt:Today()"/>

In this link got a way to apply filter on date column. However it is not working.

<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row[number(translate(substring-before(@Date,'T'),'-','')) &gt;= number(translate($curDt,'-',''))]"/>

Kindly let know to apply this filter

Was it helpful?

Solution

Got this working using below query

<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row[number(ddwrt:FormatDateTime(ddwrt:FormatDate(string(@Date),1033,1),
1033,'yyyyMMdd'))&gt;=number(ddwrt:FormatDateTime(ddwrt:FormatDate(string($curDt),1033,1),1033,'yyyyMMdd'))]"/>

$curDt is a xsl variable

It has been set to Today's date as per XSL function

The resultant values of the above ddwrt and other functions is

yyyyMMdd >= yyyyMMdd

That is if suppose todays date is 26 Dec 2017 and current list item Date value is 29 Dec 2017 the values will be;

20171229 >=20171226

Following the approach of yyyyMMdd will always yield a current number value of date comparison

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top