My Techie Blog

  Home  |   Contact  |   Syndication    |   Login
  105 Posts | 5 Stories | 402 Comments | 0 Trackbacks

News

Archives

Post Categories

Image Galleries

ADO.NET

Ajax

API/WebServices

ASP.NET Resources

BizTalk Server

Blogs I read

Free Books

How to

iOT

JavaScript

JQuery

JSLink - SharePoint

JSON

LINQ

Misc

Mobile BI

MS Business Inteliigence

Reporting Services

Responsive/MVC ASP.NET

SEO

Sharepoint Resources/Tools

SharePoint 2010 Branding

SharePoint 2010 Videos

SharePoint 2013

SilverLight

SPServices

SQL Server

Sql Server 2012

SSIS

Web Optimization Tools

Web Performace Tools

Windows 8

Windows Azure

Windows Azure

Windows Phone

WorkFlows

WSS V3

xml

I was working on a data view web part recently and i had  to filter the data based on dates.
Since the data source was web services i couldn't use  the Offset which i blogged about earlier.

When using web services to pull data in sharepoint designer you would have to use xpath.
So for example this is the soap that populates the rows

<xsl:variable name="Rows" select="/soap:Envelope/soap:Body/ddw1:GetListItemsResponse/ddw1:GetListItemsResult/ddw1:listitems/rs:data/z:row/>

But you would need to add some predicate [] and filter the date nodes.
So you can do something like this (marked in red)

<xsl:variable name="Rows" select="/soap:Envelope/soap:Body/ddw1:GetListItemsResponse/ddw1:GetListItemsResult/ddw1:listitems/rs:data/z:row[ddwrt:FormatDateTime(string(@ows_Created),1033,'yyyyMMdd') &gt;= ddwrt:FormatDateTime(string(substring-after($fd,'#')),1033,'yyyyMMdd')]"/>

For the filtering to work you need to have the date formatted  above as yyyyMMdd.
One more thing you must have noticed is the $fd variable.
This variable is created by me creating a calculated column in the list so something like this [Created]-2

So basically that the xpath is doing is get me data only when the Created date  is greater than or equal to the Created date -2 which is 2 date less than the created date.

Also not that when using web services in sharepoint designer and try to use the default filtering you won't get to see greater tha or less than in the option list comparison.:(

Hope this helps.


       
       
posted on Sunday, November 11, 2012 6:22 PM