<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dutton Software &#187; CAML</title>
	<atom:link href="http://www.duttonsoftware.com/tag/caml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.duttonsoftware.com</link>
	<description>Code, plug-ins &#38; more</description>
	<lastBuildDate>Mon, 16 Jan 2012 06:30:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>CAML queries, SSRS, and datetime fields</title>
		<link>http://www.duttonsoftware.com/2008/09/24/caml-queries-ssrs-and-datetime-fields/</link>
		<comments>http://www.duttonsoftware.com/2008/09/24/caml-queries-ssrs-and-datetime-fields/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 06:45:46 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[SQL Server Reporting Services]]></category>
		<category><![CDATA[WSS 3.0]]></category>
		<category><![CDATA[CAML]]></category>
		<category><![CDATA[DateTime]]></category>
		<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://www.duttonsoftware.com/?p=12</guid>
		<description><![CDATA[I&#8217;ve been using Enesys Software&#8217;s product RS Data Extension to query data out of SharePoint 2007 lists in SQL Server (2005) Reporting Services.  One quirk with the queries is that they use CAML and the dates must be in a particular format, ISO8601. I wanted users to use the standard date-picker, but there is no [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using Enesys Software&#8217;s product <a title="RS Data Extension" href="http://www.enesyssoftware.com/Products/EnesysRSDataExtension/Overview/tabid/72/language/en-US/Default.aspx" target="_blank">RS Data Extension</a> to query data out of SharePoint 2007 lists in SQL Server (2005) Reporting Services.  One quirk with the queries is that they use CAML and the dates must be in a particular format, ISO8601.</p>
<p>I wanted users to use the standard date-picker, but there is no way to format the date inside the query.  My work-around is a classic Reporting Services pattern &#8211; create an internal parameter that does the formatting for you.  The format string for VBScript is &#8220;yyyy-MM-ddTHH:mm:ss&#8221;.</p>
<p>Below is a screenshot of the Report Parameters dialog. I used the following code to just grab today&#8217;s date (no time).</p>
<pre>     =CDate(CDate(Now()).ToString(<span style="color: #993300;">"MM/dd/yyyy"</span>))</pre>
<p><a href="http://www.duttonsoftware.com/wp-content/uploads/2008/09/report-parameters-start-date.jpg"><img class="alignnone size-full wp-image-17" title="report-parameters-start-date" src="http://www.duttonsoftware.com/wp-content/uploads/2008/09/report-parameters-start-date.jpg" alt="" width="500" height="387" /></a></p>
<p>For the second parameter, I create an internal parameter that is dependent on the first.  This will prevent it from showing on the report and it will not be filled in until the start date is chosen.  Default value:</p>
<pre>     =CDate(Parameters!StartDate.Value).ToString(<span style="color: #993300;">"yyyy-MM-ddTHH:mm:ss"</span>)</pre>
<p><a href="http://www.duttonsoftware.com/wp-content/uploads/2008/09/report-parameters-iso8601-start-date.jpg"><img class="alignnone size-full wp-image-15" title="report-parameters-iso8601-start-date" src="http://www.duttonsoftware.com/wp-content/uploads/2008/09/report-parameters-iso8601-start-date.jpg" alt="" width="500" height="387" /></a></p>
<p>I created a test report to show how this works.  Here is the report definition:</p>
<p><a href="http://www.duttonsoftware.com/wp-content/uploads/2008/09/report-parameters-definition.jpg"><img class="alignleft size-full wp-image-14" title="report-parameters-definition" src="http://www.duttonsoftware.com/wp-content/uploads/2008/09/report-parameters-definition.jpg" alt="" width="406" height="152" /></a></p>
<p>Below is the report preview:  You can now use the parameter in your CAML query.</p>
<p><a href="http://www.duttonsoftware.com/wp-content/uploads/2008/09/report-parameters-preview.jpg"><img class="alignnone size-full wp-image-16" title="report-parameters-preview" src="http://www.duttonsoftware.com/wp-content/uploads/2008/09/report-parameters-preview.jpg" alt="" width="351" height="203" /></a></p>
<p>One other note on CAML date fields.  The time is ignored by default.  If you want to include the time, you must specify another attribute.  Example:</p>
<pre>&lt;Geq&gt;</pre>
<pre style="padding-left: 30px;">&lt;FieldRef Name="LastModified" /&gt;</pre>
<pre style="padding-left: 30px;">&lt;Value Type="DateTime" IncludeTimeValue="TRUE"&gt;@LastModified!&lt;/Value&gt;</pre>
<pre>&lt;/Geq&gt;</pre>
<p>I found a helpful post on <a title="CAML &amp; DateTime" href="http://abstractspaces.wordpress.com/2008/05/05/caml-datetime/" target="_blank">CAML &amp; DateTime</a> that might be useful for you too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.duttonsoftware.com/2008/09/24/caml-queries-ssrs-and-datetime-fields/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

