<?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>Cogniza &#187; T-SQL</title>
	<atom:link href="http://cogniza.com/wordpress/tag/t-sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://cogniza.com/wordpress</link>
	<description>Business-Intelligence Specialists</description>
	<lastBuildDate>Sat, 30 Apr 2011 13:22:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SQL Server: Date Arithmetic</title>
		<link>http://cogniza.com/wordpress/2009/11/05/sql-server-date-arithmetic/</link>
		<comments>http://cogniza.com/wordpress/2009/11/05/sql-server-date-arithmetic/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 02:32:24 +0000</pubDate>
		<dc:creator>Craig Buchanan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Technique]]></category>
		<category><![CDATA[Date]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://www.cogniza.com/blog/?p=106</guid>
		<description><![CDATA[Useful, dynamically-generated dates for SQL Server.

--[1st day  of current month]: use the GetDate(), Month(), and Year() functions to determine the current month and year.   Build a string using these values in MM/01/YYYY format.  Convert the String to DateTime.
 CAST( CAST( Month(GetDate()) AS Char(2) ) + '/01/' + CAST( Year(GetDate()) AS Char(4)) [...]]]></description>
			<content:encoded><![CDATA[<p>Useful, dynamically-generated dates for SQL Server.<span id="more-106"></span><br />
<code><br />
--[1st day  of current month]: use the GetDate(), Month(), and Year() functions to determine the current month and year.   Build a string using these values in MM/01/YYYY format.  Convert the String to DateTime.<br />
 CAST( CAST( Month(GetDate()) AS Char(2) ) + '/01/' + CAST( Year(GetDate()) AS Char(4)) AS DateTime)<br />
</code><code><br />
--[Last day of current month]: add a month to [1st day of current month], then subtract a day.<br />
DateAdd(m, 1, CAST( CAST( Month(GetDate()) AS Char(2) ) + '/01/' + CAST( Year(GetDate()) AS Char(4)) AS DateTime)) -1<br />
</code><code><br />
--[1st day of prior month]: subtract a month from [1st day of current month].<br />
DateAdd(m, -1, CAST( CAST( Month(GetDate()) AS Char(2) ) + '/01/' + CAST( Year(GetDate()) AS Char(4)) AS DateTime))<br />
</code><code><br />
--[Last day of prior month]:  subtract a day from [1st day of current month].<br />
CAST( CAST( Month(GetDate()) AS Char(2) ) + '/01/' + CAST( Year(GetDate()) AS Char(4)) AS DateTime) -1<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://cogniza.com/wordpress/2009/11/05/sql-server-date-arithmetic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

