<?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>Mitch Milam&#039;s Dynamics CRM and xRM Discussions &#187; Reporting</title>
	<atom:link href="http://blogs.infinite-x.net/category/dynamics-crm/reporting/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.infinite-x.net</link>
	<description>Sharing information with Dynamics CRM users and xRM developers</description>
	<lastBuildDate>Wed, 08 Feb 2012 16:27:42 +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>CRM 2011 Reporting: Showing Date-Only in a datetime field</title>
		<link>http://blogs.infinite-x.net/2011/07/15/crm-2011-reporting-showing-date-only-in-a-datetime-field/</link>
		<comments>http://blogs.infinite-x.net/2011/07/15/crm-2011-reporting-showing-date-only-in-a-datetime-field/#comments</comments>
		<pubDate>Fri, 15 Jul 2011 07:47:00 +0000</pubDate>
		<dc:creator>Mitch Milam</dc:creator>
				<category><![CDATA[CRM 2011]]></category>
		<category><![CDATA[Dynamics CRM]]></category>
		<category><![CDATA[Reporting]]></category>
		<category><![CDATA[MSCRM]]></category>
		<category><![CDATA[MSCRM2011]]></category>
		<category><![CDATA[MSDYNCRM]]></category>

		<guid isPermaLink="false">http://blogs.infinite-x.net/2011/07/15/crm-2011-reporting-showing-date-only-in-a-datetime-field/</guid>
		<description><![CDATA[Let&#039;s say I have a report of my CRM leads that looks like this: Very simple, just name, created on date, and their email address.&#160; The only problem is that I could really care less what time they were created, I just need the date.&#160; Here&#039;s how you fix that issue: Export the report The [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#039;s say I have a report of my CRM leads that looks like this:</p>
<p><a href="http://blogs.infinite-x.net/wp-content/uploads/2011/07/image.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.infinite-x.net/wp-content/uploads/2011/07/image_thumb.png" width="504" height="287" /></a></p>
<p>Very simple, just name, created on date, and their email address.&#160; The only problem is that I could really care less what time they were created, I just need the date.&#160; Here&#039;s how you fix that issue:</p>
<h2>Export the report</h2>
<p>The first step in this process is to export the report so that you may modify the file.</p>
<p>Edit the report then selection Actions, Download report:</p>
<p><a href="http://blogs.infinite-x.net/wp-content/uploads/2011/07/image1.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.infinite-x.net/wp-content/uploads/2011/07/image_thumb1.png" width="504" height="242" /></a></p>
<p>When Prompted, select Save, and save the report into a folder that you can easily remember.</p>
<p>&#160;</p>
<h2>Edit the report</h2>
<p>Next you need to edit the report in your favorite XML editor.&#160; I am using Visual Studio 2010.</p>
<p>You need to locate the datetime field within the XML file:</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">Textbox </span><span style="color: red">Name</span><span style="color: blue">=</span>&quot;<span style="color: blue">Table0_Details1</span>&quot;<span style="color: blue">&gt;
  &lt;</span><span style="color: #a31515">CanGrow</span><span style="color: blue">&gt;</span>true<span style="color: blue">&lt;/</span><span style="color: #a31515">CanGrow</span><span style="color: blue">&gt;
 <strong><u> &lt;</u></strong></span><strong><u><span style="color: #a31515">Value</span><span style="color: blue">&gt;</span>=Fields!createdon.Value<span style="color: blue">&lt;/</span><span style="color: #a31515">Value</span></u></strong><span style="color: blue"><strong><u>&gt;</u></strong>
  &lt;</span><span style="color: #a31515">Action</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">Hyperlink</span><span style="color: blue">&gt;</span>=Nothing<span style="color: blue">&lt;/</span><span style="color: #a31515">Hyperlink</span><span style="color: blue">&gt;
  &lt;/</span><span style="color: #a31515">Action</span><span style="color: blue">&gt;
  &lt;</span><span style="color: #a31515">Style</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">Calendar</span><span style="color: blue">&gt;</span>=Parameters!CRM_CalendarTypeCode.Value<span style="color: blue">&lt;/</span><span style="color: #a31515">Calendar</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">Language</span><span style="color: blue">&gt;</span>=Microsoft.Crm.Reporting.RdlHelper.ReportCultureInfo.GetCultureName(</pre>
<pre class="code">               Parameters!CRM_UILanguageId.Value)<span style="color: blue">&lt;/</span><span style="color: #a31515">Language</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">TextAlign</span><span style="color: blue">&gt;</span>Right<span style="color: blue">&lt;/</span><span style="color: #a31515">TextAlign</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">FontFamily</span><span style="color: blue">&gt;</span>Tahoma<span style="color: blue">&lt;/</span><span style="color: #a31515">FontFamily</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">FontSize</span><span style="color: blue">&gt;</span>8pt<span style="color: blue">&lt;/</span><span style="color: #a31515">FontSize</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">PaddingBottom</span><span style="color: blue">&gt;</span>2pt<span style="color: blue">&lt;/</span><span style="color: #a31515">PaddingBottom</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">PaddingLeft</span><span style="color: blue">&gt;</span>2pt<span style="color: blue">&lt;/</span><span style="color: #a31515">PaddingLeft</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">PaddingRight</span><span style="color: blue">&gt;</span>2pt<span style="color: blue">&lt;/</span><span style="color: #a31515">PaddingRight</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">PaddingTop</span><span style="color: blue">&gt;</span>2pt<span style="color: blue">&lt;/</span><span style="color: #a31515">PaddingTop</span><span style="color: blue">&gt;
  &lt;/</span><span style="color: #a31515">Style</span><span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">Textbox</span><span style="color: blue">&gt;

</span></pre>
<p>You need to change the highlighted line above to read:</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">Value</span><span style="color: blue">&gt;</span>=Format(CDate(Fields!createdon.Value), &quot;MM/dd/yyyy&quot;) <span style="color: blue">&lt;/</span><span style="color: #a31515">Value</span><span style="color: blue">&gt;
</span></pre>
<p>&#160;</p>
<p>Save the file.</p>
<p>&#160;</p>
<h2>Import the modified report</h2>
<p>Back in CRM, you need to import the report file.&#160; </p>
<p>Change the report type to <strong>Existing file</strong>.</p>
<p>Click the <strong>Browse</strong> button and select your .rdl file:</p>
<p><a href="http://blogs.infinite-x.net/wp-content/uploads/2011/07/image2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.infinite-x.net/wp-content/uploads/2011/07/image_thumb2.png" width="504" height="114" /></a></p>
<p>Click the Save button to save the updated report into CRM.</p>
<p>&#160;</p>
<h2>Preview the new report</h2>
<p>Here is a preview of the new report with the modified date:</p>
<p><a href="http://blogs.infinite-x.net/wp-content/uploads/2011/07/image3.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.infinite-x.net/wp-content/uploads/2011/07/image_thumb3.png" width="504" height="333" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.infinite-x.net/2011/07/15/crm-2011-reporting-showing-date-only-in-a-datetime-field/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Issue found while upgrading reports from SQL 2005 to SQL 2008</title>
		<link>http://blogs.infinite-x.net/2010/07/01/issue-found-while-upgrading-reports-from-sql-2005-to-sql-2008/</link>
		<comments>http://blogs.infinite-x.net/2010/07/01/issue-found-while-upgrading-reports-from-sql-2005-to-sql-2008/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 18:51:00 +0000</pubDate>
		<dc:creator>Mitch Milam</dc:creator>
				<category><![CDATA[Dynamics CRM]]></category>
		<category><![CDATA[Reporting]]></category>

		<guid isPermaLink="false">http://blogs.infinite-x.net/2010/07/01/issue-found-while-upgrading-reports-from-sql-2005-to-sql-2008/</guid>
		<description><![CDATA[One of my local customers recently moved from Small Business Server 2003 to Small Business Server 2008.&#160; Among other things, this required a move from SQL Server 2005 to SQL Server 2008 as well. The movement of the databases went pretty much without issue, but we ran into some strange behavior with some of the [...]]]></description>
			<content:encoded><![CDATA[<p>One of my local customers recently moved from Small Business Server 2003 to Small Business Server 2008.&#160; Among other things, this required a move from SQL Server 2005 to SQL Server 2008 as well.</p>
<p>The movement of the databases went pretty much without issue, but we ran into some strange behavior with some of the custom CRM reports they had created.&#160; The error looked something like this:</p>
<p><a href="http://blogs.infinite-x.net/images/IssuefoundwhileupgradingreportsfromSQL20_85DC/image.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.infinite-x.net/images/IssuefoundwhileupgradingreportsfromSQL20_85DC/image_thumb.png" width="504" height="139" /></a> </p>
<p>Not very helpful at all.</p>
<p>After reviewing the report in Visual Studio and still not finding any issues, I finally started looking at the system itself.&#160; That’s when I found this in the SQL Server’s Event Log:</p>
<blockquote><p>Report data set execution failure. Error: Incorrect syntax near the keyword &#039;with&#039;. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.     <br />Incorrect syntax near &#039;,&#039;.</p>
</blockquote>
<p>Hmm. It keeps getting better and better. Now what exactly does that mean?&#160; </p>
<p>&#160;</p>
<h3>Background</h3>
<p>It turns out that when the SQL commands they had written to populate the report were sent to the SQL server, they were combined with other SQL commands.</p>
<p>Unfortunately, SQL didn’t like the way the commands were combined.&#160; It wanted you to use a semi-colon ( ; ) to separate the commands so it could determine how the commands should be run.</p>
<p>Which is exactly what the error message states.</p>
<p>&#160;</p>
<h3>The Solution</h3>
<p>To fix the issue, all I did was to add a semi-colon ( ; ) to the beginning of the custom SQL statement, which looked something like this:</p>
<div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">;<span style="color: #0000ff">WITH</span> FilteredAccount AS</pre>
</p></div>
</div>
<p>And that solved the problem and the reports ran successfully.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.infinite-x.net/2010/07/01/issue-found-while-upgrading-reports-from-sql-2005-to-sql-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CRM 4.0&#8217;s Built-in SQL Functions (Part 5 of 5)</title>
		<link>http://blogs.infinite-x.net/2009/08/21/crm-4-0s-built-in-sql-functions-part-5-of-5/</link>
		<comments>http://blogs.infinite-x.net/2009/08/21/crm-4-0s-built-in-sql-functions-part-5-of-5/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 10:10:00 +0000</pubDate>
		<dc:creator>Mitch Milam</dc:creator>
				<category><![CDATA[Customization]]></category>
		<category><![CDATA[Dynamics CRM]]></category>
		<category><![CDATA[Reporting]]></category>

		<guid isPermaLink="false">http://blogs.infinite-x.net/2009/08/21/crm-4-0s-built-in-sql-functions-part-5-of-5/</guid>
		<description><![CDATA[The final installment in this series contains miscellaneous SQL functions. You may wish to review the following articles before proceeding: CRM 4.0’s Built-in SQL Functions (Part 1 of 5) CRM 4.0’s Built-in SQL Functions (Part 2 of 5) CRM 4.0’s Built-in SQL Functions (Part 3 of 5) CRM 4.0’s Built-in SQL Functions (Part 4 of [...]]]></description>
			<content:encoded><![CDATA[<p>The final installment in this series contains miscellaneous SQL functions. </p>
<p>You may wish to review the following articles before proceeding:</p>
<p><a href="http://blogs.infinite-x.net/2009/08/17/using-crm-4-0s-built-in-function-part-1-of-5/" target="_blank">CRM 4.0’s Built-in SQL Functions (Part 1 of 5)</a></p>
<p><a href="http://blogs.infinite-x.net/2009/08/18/crm-4-0s-built-in-sql-functions-part-2-of-5/" target="_blank">CRM 4.0’s Built-in SQL Functions (Part 2 of 5)</a></p>
<p><a href="http://blogs.infinite-x.net/2009/08/19/crm-4-0s-built-in-sql-functions-part-3-of-5/" target="_blank">CRM 4.0’s Built-in SQL Functions (Part 3 of 5)</a></p>
</p>
<p><a href="http://blogs.infinite-x.net/2009/08/20/crm-4-0s-built-in-sql-functions-part-4-of-5/" target="_blank">CRM 4.0’s Built-in SQL Functions (Part 4 of 5)</a></p>
<p>&#160;</p>
<p></p>
<h3>dbo.fn_FindBusinessGuid </h3>
<p>This function will return the ID for the business unit for the currently logged-on user.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_FindBusinessGuid()</pre>
</p></div>
</div>
<p>&#160;</p>
<p>
  </p>
<h3>dbo.fn_FindUserGuid </h3>
<p>This function will return the CRM ID for the currently logged-on user.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_FindUserGuid()</pre>
</p></div>
</div>
<p>&#160;</p>
<h2>Conclusion</h2>
<p>I hope you enjoyed this series which explored the built-in user-defined functions included with CRM 4.0.&#160; Hopefully, it will make your report writing quicker and more powerful.</p>
<p>I have a couple of additional articles planned that will cover some of these functions in more detail in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.infinite-x.net/2009/08/21/crm-4-0s-built-in-sql-functions-part-5-of-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CRM 4.0&#8217;s Built-in SQL Functions (Part 4 of 5)</title>
		<link>http://blogs.infinite-x.net/2009/08/20/crm-4-0s-built-in-sql-functions-part-4-of-5/</link>
		<comments>http://blogs.infinite-x.net/2009/08/20/crm-4-0s-built-in-sql-functions-part-4-of-5/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 10:52:00 +0000</pubDate>
		<dc:creator>Mitch Milam</dc:creator>
				<category><![CDATA[Customization]]></category>
		<category><![CDATA[Dynamics CRM]]></category>
		<category><![CDATA[Reporting]]></category>

		<guid isPermaLink="false">http://blogs.infinite-x.net/2009/08/20/crm-4-0s-built-in-sql-functions-part-4-of-5/</guid>
		<description><![CDATA[In this section, we’ll cover year-related functions. You may wish to review the following articles before proceeding: CRM 4.0’s Built-in SQL Functions (Part 1 of 5) CRM 4.0’s Built-in SQL Functions (Part 2 of 5) CRM 4.0’s Built-in SQL Functions (Part 3 of 5) &#160; dbo.fn_BeginOfLastYear Returns the beginning date and time for last year. [...]]]></description>
			<content:encoded><![CDATA[<p>In this section, we’ll cover year-related functions.</p>
<p>You may wish to review the following articles before proceeding:</p>
<p><a href="http://blogs.infinite-x.net/2009/08/17/using-crm-4-0s-built-in-function-part-1-of-5/" target="_blank">CRM 4.0’s Built-in SQL Functions (Part 1 of 5)</a></p>
<p><a href="http://blogs.infinite-x.net/2009/08/18/crm-4-0s-built-in-sql-functions-part-2-of-5/" target="_blank">CRM 4.0’s Built-in SQL Functions (Part 2 of 5)</a></p>
<p><a href="http://blogs.infinite-x.net/2009/08/19/crm-4-0s-built-in-sql-functions-part-3-of-5/" target="_blank">CRM 4.0’s Built-in SQL Functions (Part 3 of 5)</a></p>
<p>&#160;</p>
<h3>dbo.fn_BeginOfLastYear </h3>
<p>Returns the beginning date and time for last year.</p>
<p>This function requires a valid datetime value. </p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfLastYear(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2008-01-01 06:00:00.000</p>
<p>&#160;</p>
<p>
  </p>
<h3>dbo.fn_BeginOfNextYear </h3>
<p>Returns the beginning date and time for next year.</p>
<p>This function requires a valid datetime value. </p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfNextYear(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2010-01-01 06:00:00.000</p>
<p>&#160;</p>
<p>
  </p>
<h3>dbo.fn_BeginOfThisYear </h3>
<p>Returns the beginning date and time for this year.</p>
<p>This function requires a valid datetime value. It is assumed you will specify today’s date and time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfThisYear(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-01-01 06:00:00.000</p>
<p>&#160;</p>
<p>
  </p>
<h3>dbo.fn_BeginOfYear </h3>
<p>Returns the beginning date and time of a year.</p>
<p>This function requires a valid datetime value.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfYear(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-01-01 06:00:00.000</p>
<p>&#160;</p>
<p>
  </p>
<h3>dbo.fn_EndOfLastYear </h3>
<p>Returns the ending date and time for last year.</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will specify today’s date and time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_EndOfLastYear(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-01-01 06:00:00.000</p>
<p>&#160;</p>
<p>
  </p>
<h3>dbo.fn_EndOfNextYear </h3>
<p>Returns the ending date and time for next year.</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will specify today’s date and time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_EndOfNextYear(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2011-01-01 06:00:00.000</p>
<p>&#160;</p>
<p>
  </p>
<h3>dbo.fn_EndOfThisYear </h3>
<p>Returns the ending date and time for this year.</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will specify today’s date and time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_EndOfThisYear(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2010-01-01 06:00:00.000</p>
<p>&#160;</p>
<p>
  </p>
<h3>dbo.fn_LastXYear </h3>
<p>Returns the date from X number of years ago ( from today ).</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will specify today’s date and time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_LastXYear(GetUTCDate(), 1)</pre>
</p></div>
</div>
<p>Returns: 2008-08-16 05:00:00.000</p>
<p>&#160;</p>
<p>
  </p>
<h3>dbo.fn_NextXYear</h3>
<p>Returns a date that is X number of years in the future ( from today )</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will specify today’s date and time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_NextXYear(GetUTCDate(), 1)</pre>
</p></div>
</div>
</p>
</p>
</p>
</p>
<p>Returns: 2010-08-17 05:00:00.000</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.infinite-x.net/2009/08/20/crm-4-0s-built-in-sql-functions-part-4-of-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CRM 4.0&#8217;s Built-in SQL Functions (Part 3 of 5)</title>
		<link>http://blogs.infinite-x.net/2009/08/19/crm-4-0s-built-in-sql-functions-part-3-of-5/</link>
		<comments>http://blogs.infinite-x.net/2009/08/19/crm-4-0s-built-in-sql-functions-part-3-of-5/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 10:40:00 +0000</pubDate>
		<dc:creator>Mitch Milam</dc:creator>
				<category><![CDATA[Customization]]></category>
		<category><![CDATA[Dynamics CRM]]></category>
		<category><![CDATA[Reporting]]></category>

		<guid isPermaLink="false">http://blogs.infinite-x.net/2009/08/19/crm-4-0s-built-in-sql-functions-part-3-of-5/</guid>
		<description><![CDATA[Today we are continuing on with part three of our series on using CRM 4.0’s built-in SQL functions. You may wish to review the following articles: CRM 4.0’s Built-in SQL Functions (Part 1 of 5) CRM 4.0’s Built-in SQL Functions (Part 2 of 5) &#160; Note: The date used in the following example is 2009-08-16. [...]]]></description>
			<content:encoded><![CDATA[<p>Today we are continuing on with part three of our series on using CRM 4.0’s built-in SQL functions.</p>
<p>You may wish to review the following articles:</p>
<p><a href="http://blogs.infinite-x.net/2009/08/17/using-crm-4-0s-built-in-function-part-1-of-5/" target="_blank">CRM 4.0’s Built-in SQL Functions (Part 1 of 5)</a></p>
<p><a href="http://blogs.infinite-x.net/2009/08/18/crm-4-0s-built-in-sql-functions-part-2-of-5/" target="_blank">CRM 4.0’s Built-in SQL Functions (Part 2 of 5)</a></p>
<p>&#160;</p>
<blockquote><p>Note: The date used in the following example is 2009-08-16.</p>
</blockquote>
<p>&#160;</p>
<h3>dbo.fn_BeginOfLastMonth </h3>
<p>Return the beginning date and time of last month.</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will specify today’s date and time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfLastMonth(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-07-01 05:00:00.000 </p>
<p>&#160;</p>
<p>&#160;</p>
<h3>dbo.fn_BeginOfMonth </h3>
<p>Return the beginning date and time of a specified month.</p>
<p>This function requires a valid datetime value. </p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfMonth(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-08-01 05:00:00.000 </p>
<p>&#160;</p>
<p>&#160;</p>
<h3>dbo.fn_BeginOfNextMonth </h3>
<p>Return the beginning of next month.</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will specify today’s date and time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfNextMonth(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-09-01 05:00:00.000 </p>
<p>&#160;</p>
<p>
  </p>
<h3>dbo.fn_BeginOfThisMonth </h3>
<p>Return the beginning of this month.&#160; This function has the same functionality as dbo.fn_BeginOfMonth. </p>
<p>This function requires a valid datetime value.&#160; It is assumed you will specify today’s date and time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfThisMonth(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-08-01 05:00:00.000 </p>
<p>&#160;</p>
<p>&#160;</p>
<h3>dbo.fn_EndOfLastMonth </h3>
<p>Returns the ending date and time of last month.</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will specify today’s date and time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_EndOfLastMonth(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-08-01 05:00:00.000</p>
<p>&#160;</p>
<p>&#160;</p>
<h3>dbo.fn_EndOfNextMonth </h3>
<p>Returns the ending date and time of next month.</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will specify today’s date and time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_EndOfNextMonth(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-10-01 05:00:00.000</p>
<p>&#160;</p>
<p>
  </p>
<h3>dbo.fn_EndOfThisMonth </h3>
<p>Returns the ending date and time of this month.</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will specify today’s date and time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_EndOfThisMonth(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-09-01 05:00:00.000</p>
<p>&#160;</p>
<p>
  </p>
<h3>dbo.fn_FirstDayOfMonth </h3>
<p>Returns the first date of the month for a specified month.</p>
<p>This first parameter is a valid datetime value.&#160; The second parameter is the month you wish to check.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_FirstDayOfMonth(GetUTCDate(), 8)</pre>
</p></div>
</div>
<p>Returns: 2009-08-01 00:00:00.000</p>
<p>&#160;</p>
<p>
  </p>
<h3>dbo.fn_LastXMonth </h3>
<p>Returns the date and time from one month ago today ( assuming 30 days ago ).</p>
<p>This first parameter is a valid datetime value.&#160; The second parameter is the number of months in the past.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_LastXMonth(GetUTCDate(), 1)</pre>
</p></div>
</div>
<p>Returns: 2009-07-16 05:00:00.000</p>
<p>&#160;</p>
<p>
  </p>
<h3>dbo.fn_NextXMonth</h3>
<p>Returns the date and time from one month in the future &#8211; from today.</p>
<p>This first parameter is a valid datetime value.&#160; The second parameter is the number of months in the future.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_NextXMonth(GetUTCDate(), 1)</pre>
</p></div>
</div>
<p>Returns: 2009-09-17 05:00:00.000 </p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.infinite-x.net/2009/08/19/crm-4-0s-built-in-sql-functions-part-3-of-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CRM 4.0&#8217;s Built-in SQL Functions (Part 2 of 5)</title>
		<link>http://blogs.infinite-x.net/2009/08/18/crm-4-0s-built-in-sql-functions-part-2-of-5/</link>
		<comments>http://blogs.infinite-x.net/2009/08/18/crm-4-0s-built-in-sql-functions-part-2-of-5/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 10:21:00 +0000</pubDate>
		<dc:creator>Mitch Milam</dc:creator>
				<category><![CDATA[Customization]]></category>
		<category><![CDATA[Dynamics CRM]]></category>
		<category><![CDATA[Reporting]]></category>

		<guid isPermaLink="false">http://blogs.infinite-x.net/2009/08/18/crm-4-0s-built-in-sql-functions-part-2-of-5/</guid>
		<description><![CDATA[As we continue onto the second article in our set, you may wish to review the previous article: &#160;CRM 4.0’s Built-in SQL Functions (Part 1 of 5) &#160; Note: The date used in the following example is 2009-08-16. &#160; dbo.fn_BeginOfLastWeek Returns the beginning date and time for last week. This function requires a valid datetime [...]]]></description>
			<content:encoded><![CDATA[<p>As we continue onto the second article in our set, you may wish to review the previous article:</p>
<p>&#160;<a href="http://blogs.infinite-x.net/2009/08/17/using-crm-4-0s-built-in-function-part-1-of-5/" target="_blank">CRM 4.0’s Built-in SQL Functions (Part 1 of 5)</a></p>
<p>&#160;</p>
<blockquote><p>Note: The date used in the following example is 2009-08-16.</p>
</blockquote>
<p>&#160;</p>
<h3>dbo.fn_BeginOfLastWeek </h3>
<p>Returns the beginning date and time for last week.</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will specify today’s date and time</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfLastWeek(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-08-23 05:00:00.000 </p>
<p>
  </p>
<h3>dbo.fn_BeginOfLastXWeek </h3>
<p>Returns the beginning date and time for a week X weeks ago.</p>
<p>The first parameter is the date in question, the second parameter is the number of weeks before that date.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfLastXWeek(GetUTCDate(), 1)</pre>
</p></div>
</div>
<p>Returns: 2009-08-09 05:00:00.000 </p>
<p>
  </p>
<h3>dbo.fn_BeginOfNextWeek </h3>
<p>Returns the beginning date and time for next week.</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will specify today’s date and time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfNextWeek(GetUTCDate())</pre>
</p></div>
</div>
<p>2009-08-23 05:00:00.000 </p>
<p>
  </p>
<h3>dbo.fn_BeginOfWeek </h3>
<p>Returns the beginning date and time for a specified date.</p>
<p>This function requires a valid datetime value.&#160; </p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfWeek(GetUTCDate())</pre>
</p></div>
</div>
<p>2009-08-16 05:00:00.000 </p>
<p>
  </p>
<h3>dbo.fn_BeginOfThisWeek </h3>
<p>Returns the beginning date and time for this week.</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will specify today’s date and time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfThisWeek(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-08-16 05:00:00.000 </p>
<p>
  </p>
<h3>dbo.fn_EndOfLastWeek </h3>
<p>Returns the ending date and time for last week.</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will specify today’s date and time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_EndOfLastWeek(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-08-16 05:00:00.000 </p>
<p>
  </p>
<h3>dbo.fn_EndOfNextWeek </h3>
<p>Returns the ending date and time for nextweek.</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will specify today’s date and time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_EndOfNextWeek(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-08-30 05:00:00.000 </p>
<p>
  </p>
<h3>dbo.fn_EndOfNextXWeek </h3>
<p>Returns the beginning date and time for a week X weeks in the future.</p>
<p>The first parameter is the date in question, the second parameter is the number of weeks after that date.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_EndOfNextXWeek(GetUTCDate(), 1)</pre>
</p></div>
</div>
<p>Returns: 2009-08-24 05:00:00.000 </p>
<p>
  </p>
<h3>dbo.fn_EndOfThisWeek </h3>
<p>Returns the ending date and time for this week.</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will specify today’s date and time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_EndOfThisWeek(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-08-23 05:00:00.000 </p>
<p>
  </p>
<h3>dbo.fn_NTDayOfWeek</h3>
<p>Returns the day of the week. 0 = Sunday, 6 = Saturday.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_NTDayOfWeek(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 0 ( for Sunday ) </p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.infinite-x.net/2009/08/18/crm-4-0s-built-in-sql-functions-part-2-of-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CRM 4.0&#8217;s Built-in SQL Functions (Part 1 of 5)</title>
		<link>http://blogs.infinite-x.net/2009/08/17/using-crm-4-0s-built-in-function-part-1-of-5/</link>
		<comments>http://blogs.infinite-x.net/2009/08/17/using-crm-4-0s-built-in-function-part-1-of-5/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 10:58:00 +0000</pubDate>
		<dc:creator>Mitch Milam</dc:creator>
				<category><![CDATA[Dynamics CRM]]></category>
		<category><![CDATA[Reporting]]></category>

		<guid isPermaLink="false">http://blogs.infinite-x.net/2009/08/17/using-crm-4-0s-built-in-function-part-1-of-5/</guid>
		<description><![CDATA[As I mentioned in a previous article, CRM 4.0 includes a group of user-defined functions that are commonly used within SQL Reporting Services reports to query CRM data.&#160; I first noticed these functions when modifying a report created using the CRM Report Wizard. That got me to thinking that I needed to explore these functions [...]]]></description>
			<content:encoded><![CDATA[<p>As I mentioned in a previous <a href="http://blogs.infinite-x.net/2009/02/20/using-built-in-crm-functions-when-writing-sql-reports/" target="_blank">article</a>, CRM 4.0 includes a group of user-defined functions that are commonly used within SQL Reporting Services reports to query CRM data.&#160; I first noticed these functions when modifying a report created using the CRM Report Wizard.</p>
<p>That got me to thinking that I needed to explore these functions in more detail to determine if they would be of use to me when producing my own reports or simply when creating custom SQL queries to query CRM data.</p>
<p>Since there are so many functions, I’ve decided to break our discussion into five articles so as not to overwhelm you with data.</p>
<h2>Overview</h2>
<p>The first thing you will notice is that most of the functions work with dates and times.&#160; This is great for us because most date math can be one of the hardest topics to master and it also makes your SQL queries difficult to read.</p>
<p>The second point that requires attention is the fact that all dates within CRM are stored in <a href="http://en.wikipedia.org/wiki/UTC" target="_blank">Coordinated Universal Time</a>, or UTC, as it is called.&#160; This was done ( I’m sure ) to allow for a consistent method for performing date calculations without requiring the developer to take time zones into account.&#160; The only issue is when a human looks at the dates, they look funny because they are not reconciled with the local time zone and don’t match what a person <em>thinks</em> the date and time should be.</p>
<p>So, let’s get started with our review.</p>
<p>&#160;</p>
<blockquote><p><strong>Notes:</strong></p>
<p>I will be using Eastern Daylight Savings Time for these articles.&#160; This is UTC –5 hours.</p>
<p>You should also note that UTC times are in 24-hour format, not 12-hour format.</p>
<p>In my examples, I’ll be using the SQL function GetUTCDate() which returns the current date and time in UTC format.</p>
<p>It would also appear that the beginning of one day is actually the same as the ending of the previous day.</p>
<p>Today’s date is 2009-08-16</p>
</blockquote>
<p>&#160;</p>
<h3>dbo.fn_BeginOfDay</h3>
<p>Returns the date and time of the beginning time for a specified day.&#160; The day starts at midnight ( 00:00 ).</p>
<p>This function requires a valid datetime value.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfDay(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns the value: 2009-08-16 05:00:00.000 </p>
<p>&#160;</p>
<h3>dbo.fn_BeginOfLastXDay</h3>
<p>Returns the beginning of a day, X number of days in the past.</p>
<p>The first parameter is the date in question, the second parameter is the number of days prior to that date.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfLastXDay(GetUTCDate(), 1)</pre>
</p></div>
</div>
<p>Returns: 2009-08-15 05:00:00.000 </p>
<p>&#160;</p>
<h3>dbo.fn_BeginOfToday</h3>
<p>Returns the beginning of today.</p>
<p>This function requires a valid datetime value.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfToday(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-08-16 05:00:00.000 </p>
<p>&#160;</p>
<h3>dbo.fn_BeginOfTomorrow</h3>
<p>Returns the beginning of tomorrow.</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will pass GetUTCDate() to properly retrieve today’s date.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfTomorrow(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-08-17 05:00:00.000 </p>
<p>&#160;</p>
<h3>dbo.fn_BeginOfYesterday</h3>
<p>Returns the beginning of yesterday.</p>
<p>This function requires a valid datetime value.&#160; This function is actually the same as dbo.fn_BeginOfDay().&#160; It is assumed you will pass GetUTCDate() to properly retrieve today’s date..</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfYesterday(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-08-15 05:00:00.000 </p>
<p>&#160;</p>
<h3>dbo.fn_EndOfNextSevenDay</h3>
<p>Returns the beginning of the day for a date 7 days into the future.</p>
<p>This function requires a valid datetime value.&#160; </p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_EndOfNextSevenDay(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-08-24 05:00:00.000</p>
<p>&#160;</p>
<h3>dbo.fn_EndOfNextXDay</h3>
<p>Returns the beginning of the day for the <u>day after</u> a day X days into the future.</p>
<p>The first parameter is the date in question, the second parameter is the number of days after that date.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_EndOfNextXDay(GetUTCDate(), 1)</pre>
</p></div>
</div>
<p>Returns: 2009-08-18 05:00:00.000 </p>
<p>&#160;</p>
<h3>dbo.fn_BeginOfLastSevenDay</h3>
<p>Returns the beginning of the day, for a day 7 days into the past.</p>
<p>This function requires a valid datetime value.&#160; </p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfLastSevenDay(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-08-09 05:00:00.000</p>
<p>&#160;</p>
</p>
<h3>dbo.fn_EndOfToday</h3>
<p>Returns the end of today.</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will pass GetUTCDate() to properly retrieve today’s date.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_EndOfToday(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-08-17 05:00:00.000</p>
<p>&#160;</p>
<h3>dbo.fn_EndOfTomorrow</h3>
<p>Returns the end of tomorrow.</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will pass GetUTCDate() to properly retrieve today’s date.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_EndOfTomorrow(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-08-18 05:00:00.000 </p>
<p>&#160;</p>
<h3>dbo.fn_EndOfYesterday</h3>
<p>Returns the end of yesterday.</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will pass GetUTCDate() to properly retrieve today’s date.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_EndOfYesterday(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-08-16 05:00:00.000</p>
<p>&#160;</p>
<h3>dbo.fn_BeginOfHour</h3>
<p>Returns the beginning of the current hour.</p>
<p>This function requires a valid datetime value.&#160; It is assumed you will pass GetUTCDate() to properly retrieve today’s date and time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfHour(GetUTCDate())</pre>
</p></div>
</div>
<p>Returns: 2009-08-16 17:00:00.000 </p>
<p>&#160;</p>
<h3>dbo.fn_BeginOfLastXHour</h3>
<p>Returns the beginning of the last hour, X hours in the past.</p>
<p>The first parameter is the date/time in question, the second parameter is the number of hours previous to the current time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_BeginOfLastXHour(GetUTCDate(), 1)</pre>
</p></div>
</div>
<p>Returns: 2009-08-16 16:00:00.000</p>
<p>&#160;</p>
<h3>dbo.fn_EndOfNextXHour</h3>
<p>Returns the end of the next hour, X hours into the future.</p>
<p>The first parameter is the date/time in question, the second parameter is the number of hours previous to the current time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_EndOfNextXHour(GetUTCDate(), 1)</pre>
</p></div>
</div>
</p>
</p>
</p>
</p>
</p>
</p>
</p>
</p>
<p>Returns: 2009-08-16 19:00:00.000</p>
</p>
<p>&#160;</p>
<h2>All of this UTC stuff is giving me a headache!</h2>
<p>Welcome to the club.&#160; Luckily, the CRM team gave us a function to covert everything to the local time zone:</p>
<h3>dbo.fn_UTCToLocalTime</h3>
<p>Converts a UTC datetime value into a local date and time value.&#160; Using modifications of our examples above:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_UTCToLocalTime(dbo.fn_BeginOfHour(GetUTCDate()))</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_UTCToLocalTime(dbo.fn_BeginOfLastXHour(GetUTCDate(), 1))</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_UTCToLocalTime(dbo.fn_EndOfNextXHour(GetUTCDate(), 1))</pre>
</p></div>
</div>
<p>Returns:</p>
<p><strong>Beginning of Hour: </strong>2009-08-16 12:00:00.000</p>
<p><strong>Beginning of Last X Hour:</strong> 2009-08-16 11:00:00.000</p>
<p><strong>Beginning of Next X Hour: </strong>2009-08-16 14:00:00.000</p>
<p>&#160; </p>
<h3>dbo.fn_LocalTimeToUTC</h3>
<p>Just the opposite of dbo.fn_UTCToLocalTime, this function converts local time to UTC time.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_LocalTimeToUTC(GetDate())</pre>
</p></div>
</div>
<p>Returns: 2009-08-16 20:56:56.827 </p>
<p>&#160;</p>
</p>
<h2></h2>
<h2>Conclusion</h2>
</p>
<p>Today we started covering the user-defined SQL functions found inside CRM 4.0 database.&#160; Granted, sometimes the data that is returned doesn’t quite look right because all dates and times are in UTC format.&#160; I just have to say that you need to trust the results because this is what CRM uses on an everyday basis.</p>
<p>If you are ever confused by the results, I would suggest wrapping your query in a dbo.fn_UTCToLocalTIme() function to see what is returned.&#160; Like this:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">select</span> dbo.fn_UTCToLocalTime(dbo.fn_BeginOfLastSevenDay(GetUTCDate()))</pre>
</p></div>
</div>
<p>Returns: 2009-08-09 00:00:00.000 </p>
<p>&#160;</p>
<p>Good luck.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.infinite-x.net/2009/08/17/using-crm-4-0s-built-in-function-part-1-of-5/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using built-in CRM functions when writing SQL Reports</title>
		<link>http://blogs.infinite-x.net/2009/02/20/using-built-in-crm-functions-when-writing-sql-reports/</link>
		<comments>http://blogs.infinite-x.net/2009/02/20/using-built-in-crm-functions-when-writing-sql-reports/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 17:35:22 +0000</pubDate>
		<dc:creator>Mitch Milam</dc:creator>
				<category><![CDATA[Customization]]></category>
		<category><![CDATA[Dynamics CRM]]></category>
		<category><![CDATA[Reporting]]></category>

		<guid isPermaLink="false">http://blogs.infinite-x.net/2009/02/20/using-built-in-crm-functions-when-writing-sql-reports/</guid>
		<description><![CDATA[If you&#039;ve ever worked with CRM&#039;s Advanced Find you know what an amazing number of built-in date query parameters there are.&#160; It turns out, that those query parameters have corresponding user-defined SQL functions that you can use in your own queries for operations such as custom reports. Here is a list of some of the [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#039;ve ever worked with CRM&#039;s Advanced Find you know what an amazing number of built-in date query parameters there are.&nbsp; It turns out, that those query parameters have corresponding user-defined SQL functions that you can use in your own queries for operations such as custom reports.</p>
<p>Here is a list of some of the more common date functions:</p>
<p>fn_BeginOfDay<br />fn_BeginOfHour<br />fn_BeginOfLastMonth<br />fn_BeginOfLastSevenDay<br />fn_BeginOfLastWeek<br />fn_BeginOfLastXDay<br />fn_BeginOfLastXHour<br />fn_BeginOfLastXWeek<br />fn_BeginOfLastYear<br />fn_BeginOfMonth<br />fn_BeginOfNextMonth<br />fn_BeginOfNextWeek<br />fn_BeginOfNextYear<br />fn_BeginOfThisMonth<br />fn_BeginOfThisWeek<br />fn_BeginOfThisYear<br />fn_BeginOfToday<br />fn_BeginOfTomorrow<br />fn_BeginOfWeek<br />fn_BeginOfYear<br />fn_BeginOfYesterday<br />fn_EndOfLastMonth<br />fn_EndOfLastWeek<br />fn_EndOfLastYear<br />fn_EndOfNextMonth<br />fn_EndOfNextSevenDay<br />fn_EndOfNextWeek<br />fn_EndOfNextXDay<br />fn_EndOfNextXHour<br />fn_EndOfNextXWeek<br />fn_EndOfNextYear<br />fn_EndOfThisMonth<br />fn_EndOfThisWeek<br />fn_EndOfThisYear<br />fn_EndOfToday<br />fn_EndOfTomorrow<br />fn_EndOfYesterday<br />fn_FirstDayOfMonth<br />fn_LastXMonth<br />fn_LastXYear<br />fn_LocalTimeToUTC<br />fn_NextXMonth<br />fn_NextXYear<br />fn_NTDayOfWeek<br /> 
<p>If you would like to see these functions in action, copy the following script into SQL Management Studio and run it ( after connecting to the CRM database ):
<p>&nbsp;
<p>select &#039;fn_BeginOfDay&#039; as &#034;Function&#034;,&nbsp; dbo.fn_BeginOfDay(GetDate()) as &#034;Value&#034;<br />union<br />select &#039;fn_BeginOfHour&#039;,&nbsp; dbo.fn_BeginOfHour(GetDate())<br />union<br />select &#039;fn_BeginOfLastMonth&#039;,&nbsp; dbo.fn_BeginOfLastMonth(GetDate())<br />union<br />select &#039;fn_BeginOfLastSevenDay&#039;,&nbsp; dbo.fn_BeginOfLastSevenDay(GetDate())<br />union<br />select &#039;fn_BeginOfLastWeek&#039;,&nbsp; dbo.fn_BeginOfLastWeek(GetDate())<br />union<br />select &#039;fn_BeginOfLastXDay&#039;,&nbsp; dbo.fn_BeginOfLastXDay(GetDate(), 1)<br />union<br />select &#039;fn_BeginOfLastXHour&#039;,&nbsp; dbo.fn_BeginOfLastXHour(GetDate(), 1)<br />union<br />select &#039;fn_BeginOfLastXWeek&#039;,&nbsp; dbo.fn_BeginOfLastXWeek(GetDate(), 2)<br />union<br />select &#039;fn_BeginOfLastYear&#039;,&nbsp; dbo.fn_BeginOfLastYear(GetDate())<br />union<br />select &#039;fn_BeginOfMonth&#039;,&nbsp; dbo.fn_BeginOfMonth(GetDate())<br />union<br />select &#039;fn_BeginOfNextMonth&#039;,&nbsp; dbo.fn_BeginOfNextMonth(GetDate())<br />union<br />select &#039;fn_BeginOfNextWeek&#039;,&nbsp; dbo.fn_BeginOfNextWeek(GetDate())<br />union<br />select &#039;fn_BeginOfNextYear&#039;,&nbsp; dbo.fn_BeginOfNextYear(GetDate())<br />union<br />select &#039;fn_BeginOfThisMonth&#039;,&nbsp; dbo.fn_BeginOfThisMonth(GetDate())<br />union<br />select &#039;fn_BeginOfThisWeek&#039;,&nbsp; dbo.fn_BeginOfThisWeek(GetDate())<br />union<br />select &#039;fn_BeginOfThisYear&#039;,&nbsp; dbo.fn_BeginOfThisYear(GetDate())<br />union<br />select &#039;fn_BeginOfToday&#039;,&nbsp; dbo.fn_BeginOfToday(GetDate())<br />union<br />select &#039;fn_BeginOfTomorrow&#039;,&nbsp; dbo.fn_BeginOfTomorrow(GetDate())<br />union<br />select &#039;fn_BeginOfWeek&#039;,&nbsp; dbo.fn_BeginOfWeek(GetDate())<br />union<br />select &#039;fn_BeginOfYear&#039;,&nbsp; dbo.fn_BeginOfYear(GetDate())<br />union<br />select &#039;fn_BeginOfYesterday&#039;,&nbsp; dbo.fn_BeginOfYesterday(GetDate())<br />union<br />select &#039;fn_EndOfLastMonth&#039;,&nbsp; dbo.fn_EndOfLastMonth(GetDate())<br />union<br />select &#039;fn_EndOfLastWeek&#039;,&nbsp; dbo.fn_EndOfLastWeek(GetDate())<br />union<br />select &#039;fn_EndOfLastYear&#039;,&nbsp; dbo.fn_EndOfLastYear(GetDate())<br />union<br />select &#039;fn_EndOfNextMonth&#039;,&nbsp; dbo.fn_EndOfNextMonth(GetDate())<br />union<br />select &#039;fn_EndOfNextSevenDay&#039;,&nbsp; dbo.fn_EndOfNextSevenDay(GetDate())<br />union<br />select &#039;fn_EndOfNextWeek&#039;,&nbsp; dbo.fn_EndOfNextWeek(GetDate())<br />union<br />select &#039;fn_EndOfNextXDay&#039;,&nbsp; dbo.fn_EndOfNextXDay(GetDate(), 1)<br />union<br />select &#039;fn_EndOfNextXHour&#039;,&nbsp; dbo.fn_EndOfNextXHour(GetDate(), 1)<br />union<br />select &#039;fn_EndOfNextXWeek&#039;,&nbsp; dbo.fn_EndOfNextXWeek(GetDate(), 1)<br />union<br />select &#039;fn_EndOfNextYear&#039;,&nbsp; dbo.fn_EndOfNextYear(GetDate())<br />union<br />select &#039;fn_EndOfThisMonth&#039;,&nbsp; dbo.fn_EndOfThisMonth(GetDate())<br />union<br />select &#039;fn_EndOfThisWeek&#039;,&nbsp; dbo.fn_EndOfThisWeek(GetDate())<br />union<br />select &#039;fn_EndOfThisYear&#039;,&nbsp; dbo.fn_EndOfThisYear(GetDate())<br />union<br />select &#039;fn_EndOfToday&#039;,&nbsp; dbo.fn_EndOfToday(GetDate())<br />union<br />select &#039;fn_EndOfTomorrow&#039;,&nbsp; dbo.fn_EndOfTomorrow(GetDate())<br />union<br />select &#039;fn_EndOfYesterday&#039;,&nbsp; dbo.fn_EndOfYesterday(GetDate())<br />union<br />select &#039;fn_FirstDayOfMonth&#039;,&nbsp; dbo.fn_FirstDayOfMonth(GetDate(), 10)<br />union<br />select &#039;fn_LastXMonth&#039;,&nbsp; dbo.fn_LastXMonth(GetDate(), 1)<br />union<br />select &#039;fn_LastXYear&#039;,&nbsp; dbo.fn_LastXYear(GetDate(), 1)<br />union<br />select &#039;fn_NextXMonth&#039;,&nbsp; dbo.fn_NextXMonth(GetDate(), 1)<br />union<br />select &#039;fn_NextXYear&#039;,&nbsp; dbo.fn_NextXYear(GetDate(), 1) </p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.infinite-x.net/2009/02/20/using-built-in-crm-functions-when-writing-sql-reports/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using Filtered Views with CRM 3.0</title>
		<link>http://blogs.infinite-x.net/2006/09/07/using-filtered-views-with-crm-30/</link>
		<comments>http://blogs.infinite-x.net/2006/09/07/using-filtered-views-with-crm-30/#comments</comments>
		<pubDate>Thu, 07 Sep 2006 16:03:13 +0000</pubDate>
		<dc:creator>Mitch Milam</dc:creator>
				<category><![CDATA[Dynamics CRM]]></category>
		<category><![CDATA[Reporting]]></category>

		<guid isPermaLink="false">http://blogs.infinite-x.net/2006/09/07/using-filtered-views-with-crm-30/</guid>
		<description><![CDATA[Some of my customers use Microsoft Excel or Access to pull data from the CRM system in order to produce custom reports, or in one instance, to interface with a third-party bulk-email application. CRM 3.0 has a set of SQL Database Views, called Filtered Views, that are constructed in such a way that CRM Security roles [...]]]></description>
			<content:encoded><![CDATA[<p>Some of my customers use Microsoft Excel or Access to pull data from the CRM system in order to produce custom reports, or in one instance, to interface with a third-party bulk-email application.</p>
<p>CRM 3.0 has a set of SQL Database Views, called <a href="http://search.msdn.microsoft.com/search/Redirect.aspx?title=CRM3.0+Filtered+Views&#038;url=http://msdn.microsoft.com/library/en-us/CrmSdk3_0/htm/v3d0filteredviews.asp">Filtered Views</a>, that are constructed in such a way that CRM Security roles are maintained and you can retrieve nothing using one of these views that you would not ordinarily see while using the CRM application.</p>
<p>One aspect of using filtered views that you must take into consideration is the fact that all data ( that you have access to ) will be retrieved from the specified Entity.  This means both Inactive and Active records.</p>
<p>If you don&#039;t take Inactive records into consideration your result set could be drastically different than what you expected and  you may inadvertently expend resources on inactive customers.</p>
<p>Luckily, CRM provides two data fields that can be used to filter your query:</p>
<table style="float: left; background-color: white; text-align: left; border: black 1px solid" cellspacing="2" cellpadding="4" width="50%" border="1">
<tr>
<td bgcolor="#99ccff"><strong>SQL Column</strong></td>
<td bgcolor="#99ccff"><strong>Value</strong></td>
</tr>
<tr>
<td>statuscode</td>
<td>1 = Active </p>
<p>2 = Inactive</td>
</tr>
<tr>
<td>statuscodename</td>
<td>Active </p>
<p>or</p>
<p>Inactive</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>So, here is how you would use the above:</p>
<p> </p>
<div class="wlWriterSmartContent" id="C411E4BC-FA5A-4068-9F25-1AA2B5A98D76:3dd82559-bc5c-40d4-83a1-d51c670357cd" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<div style="display: block; background-color: #f7f7ff">
<pre>
<table>
<tr>
<td><span style="color: #008000">--</span></td>
</tr>
<tr>
<td><span style="color: #008000">-- Show only active Accounts</span></td>
</tr>
<tr>
<td><span style="color: #008000">--</span></td>
</tr>
<tr>
<td><a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&#038;siteid=us%2Fdev&#038;p=1&#038;nq=NEW&#038;qu=select&#038;IntlSearch=&#038;boolean=PHRASE&#038;ig=01&#038;i=09&#038;i=99">select</a> * <a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&#038;siteid=us%2Fdev&#038;p=1&#038;nq=NEW&#038;qu=from&#038;IntlSearch=&#038;boolean=PHRASE&#038;ig=01&#038;i=09&#038;i=99">from</a> FilteredAccount <a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&#038;siteid=us%2Fdev&#038;p=1&#038;nq=NEW&#038;qu=where&#038;IntlSearch=&#038;boolean=PHRASE&#038;ig=01&#038;i=09&#038;i=99">where</a> statuscode = 1</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><span style="color: #008000">--</span></td>
</tr>
<tr>
<td><span style="color: #008000">-- Show only active Contacts</span></td>
</tr>
<tr>
<td><span style="color: #008000">--</span></td>
</tr>
<tr>
<td><a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&#038;siteid=us%2Fdev&#038;p=1&#038;nq=NEW&#038;qu=select&#038;IntlSearch=&#038;boolean=PHRASE&#038;ig=01&#038;i=09&#038;i=99">select</a> * <a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&#038;siteid=us%2Fdev&#038;p=1&#038;nq=NEW&#038;qu=from&#038;IntlSearch=&#038;boolean=PHRASE&#038;ig=01&#038;i=09&#038;i=99">from</a> FilteredContact <a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&#038;siteid=us%2Fdev&#038;p=1&#038;nq=NEW&#038;qu=where&#038;IntlSearch=&#038;boolean=PHRASE&#038;ig=01&#038;i=09&#038;i=99">where</a> statuscode = 1</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</pre>
</div>
</div>
<p>This code instructs SQL Server to return all rows where the statuscode is equal to 1, which is an Active Account or Contact.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.infinite-x.net/2006/09/07/using-filtered-views-with-crm-30/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Dynamics CRM 3.0: Error Accessing Reports</title>
		<link>http://blogs.infinite-x.net/2006/07/06/dynamics-crm-30-error-accessing-reports/</link>
		<comments>http://blogs.infinite-x.net/2006/07/06/dynamics-crm-30-error-accessing-reports/#comments</comments>
		<pubDate>Thu, 06 Jul 2006 14:55:28 +0000</pubDate>
		<dc:creator>Mitch Milam</dc:creator>
				<category><![CDATA[Dynamics CRM]]></category>
		<category><![CDATA[Reporting]]></category>

		<guid isPermaLink="false">http://blogs.infinite-x.net/2006/07/06/dynamics-crm-30-error-accessing-reports/</guid>
		<description><![CDATA[I ran into a very strange issue last week at one of our local customers. One of the users was receiving an error when she attempted to access the Workplace Reports group. It turns out, that for some unknown reason, she was not part of the Active Directory security group ReportingGroup, which is used by [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into a very strange issue last week at one of our local customers.</p>
<p>One of the users was receiving an error when she attempted to access the Workplace Reports group.</p>
<p>It turns out, that for some unknown reason, she was not part of the Active Directory security group <strong>ReportingGroup</strong>, which is used by CRM to control access to the reporting server, etc.</p>
<p>Adding her to this group corrected the issue.</p>
<p>What I don&#039;t understand, is how this happened. This user was added to the system after the initial installation and Automatic Group Management was enabled so she should have been added to the ReportingGroup automatically.</p>
<p>Anyway,if you ever run into Report access errors, check the user&#039;s membership into the ReportingGroup.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.infinite-x.net/2006/07/06/dynamics-crm-30-error-accessing-reports/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

