<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: DateTime Manipulation</title>
	<atom:link href="http://sqlinthewild.co.za/index.php/2007/11/05/datetime-manipulation/feed/" rel="self" type="application/rss+xml" />
	<link>http://sqlinthewild.co.za/index.php/2007/11/05/datetime-manipulation/</link>
	<description>A discussion on SQL Server</description>
	<lastBuildDate>Mon, 14 May 2012 23:51:41 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Gail</title>
		<link>http://sqlinthewild.co.za/index.php/2007/11/05/datetime-manipulation/comment-page-1/#comment-25</link>
		<dc:creator>Gail</dc:creator>
		<pubDate>Wed, 28 Jul 2010 18:15:28 +0000</pubDate>
		<guid isPermaLink="false">http://sqlinthewild.co.za/index.php/2007/11/05/datetime-manipulation/#comment-25</guid>
		<description>Mark, I suggest that you post the question on one of the SQL forums. SQLServerCentral, SQLTeam or the MSDN forums. A blog comment is not the best place to ask questions unrelated to the post.</description>
		<content:encoded><![CDATA[<p>Mark, I suggest that you post the question on one of the SQL forums. SQLServerCentral, SQLTeam or the MSDN forums. A blog comment is not the best place to ask questions unrelated to the post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://sqlinthewild.co.za/index.php/2007/11/05/datetime-manipulation/comment-page-1/#comment-24</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Wed, 28 Jul 2010 16:10:07 +0000</pubDate>
		<guid isPermaLink="false">http://sqlinthewild.co.za/index.php/2007/11/05/datetime-manipulation/#comment-24</guid>
		<description>I&#039;m trying to update a query (and it&#039;s a query only) that will run from the 15th of the prior month to the 14th of the current month and have the date automatically update depending on the date the query is actually run.  Date format is YYYY-MM-DD.  Format is DATETIME.  Thanks!</description>
		<content:encoded><![CDATA[<p>I&#8217;m trying to update a query (and it&#8217;s a query only) that will run from the 15th of the prior month to the 14th of the current month and have the date automatically update depending on the date the query is actually run.  Date format is YYYY-MM-DD.  Format is DATETIME.  Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gail</title>
		<link>http://sqlinthewild.co.za/index.php/2007/11/05/datetime-manipulation/comment-page-1/#comment-23</link>
		<dc:creator>Gail</dc:creator>
		<pubDate>Fri, 21 Aug 2009 08:01:45 +0000</pubDate>
		<guid isPermaLink="false">http://sqlinthewild.co.za/index.php/2007/11/05/datetime-manipulation/#comment-23</guid>
		<description>It is indeed for BETWEEN. As I&#039;m sure you know, BETWEEN is inclusive on both bounds. So
BETWEEN @SomeDate and DATEADD(dd,1,@SomeDate)
will include midnight of both days, which may not be what&#039;s wanted.
To use BETWEEN and not get midnight on the other side, remove 3 ms from the end date as that&#039;s the smallest granularity of SQL&#039;s DATETIME (NB, not the newer SQL 2008 date types though)

So BETWEEN @SomeDate and DATEADD(ms,-3,DATEADD(dd,1,@SomeDate))
Will get you midnight of the starting date, but not the ending.

The other way is not to use BETWEEN at all, but to use inequalities
WHERE SomeColumn &gt;= @SomeDate and SomeColumn &lt; DATEADD(dd,1,@SomeDate)</description>
		<content:encoded><![CDATA[<p>It is indeed for BETWEEN. As I&#8217;m sure you know, BETWEEN is inclusive on both bounds. So<br />
BETWEEN @SomeDate and DATEADD(dd,1,@SomeDate)<br />
will include midnight of both days, which may not be what&#8217;s wanted.<br />
To use BETWEEN and not get midnight on the other side, remove 3 ms from the end date as that&#8217;s the smallest granularity of SQL&#8217;s DATETIME (NB, not the newer SQL 2008 date types though)</p>
<p>So BETWEEN @SomeDate and DATEADD(ms,-3,DATEADD(dd,1,@SomeDate))<br />
Will get you midnight of the starting date, but not the ending.</p>
<p>The other way is not to use BETWEEN at all, but to use inequalities<br />
WHERE SomeColumn >= @SomeDate and SomeColumn < DATEADD(dd,1,@SomeDate)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bob H</title>
		<link>http://sqlinthewild.co.za/index.php/2007/11/05/datetime-manipulation/comment-page-1/#comment-22</link>
		<dc:creator>Bob H</dc:creator>
		<pubDate>Fri, 21 Aug 2009 00:45:50 +0000</pubDate>
		<guid isPermaLink="false">http://sqlinthewild.co.za/index.php/2007/11/05/datetime-manipulation/#comment-22</guid>
		<description>Gail, why do you need to know 3 ms to whatever?

Is it for use with a BETWEEN?</description>
		<content:encoded><![CDATA[<p>Gail, why do you need to know 3 ms to whatever?</p>
<p>Is it for use with a BETWEEN?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

