<?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"
	>
<channel>
	<title>Comments on: Dates can easily be the hardest datatype to work with.</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/sql-server/dates-can-easily-be-the-hardest-datatype-to-work-with/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/sql-server/dates-can-easily-be-the-hardest-datatype-to-work-with/</link>
	<description></description>
	<pubDate>Mon, 23 Nov 2009 11:39:15 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: mrdenny</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/dates-can-easily-be-the-hardest-datatype-to-work-with/#comment-291</link>
		<dc:creator>mrdenny</dc:creator>
		<pubDate>Thu, 24 Sep 2009 19:46:37 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/?p=693#comment-291</guid>
		<description>You should be able to do something like this without two much overhead.

[CODE]WHERE tab1.col1 BETWEEN CAST(convert(varchar(10, tab2.col1, 101) as datetime) and dateadd(ms, -3, dateadd(dd, 1, cast(convert(varchar(10), tab2.col1, 101) as datetime)))[/CODE]

Check my Parens, I think they are correct, but I'm not sure.</description>
		<content:encoded><![CDATA[<p>You should be able to do something like this without two much overhead.</p>
<pre>WHERE tab1.col1 BETWEEN CAST(convert(varchar(10, tab2.col1, 101) as datetime) and dateadd(ms, -3, dateadd(dd, 1, cast(convert(varchar(10), tab2.col1, 101) as datetime)))</pre>
<p>Check my Parens, I think they are correct, but I&#8217;m not sure.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sowmi</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/dates-can-easily-be-the-hardest-datatype-to-work-with/#comment-285</link>
		<dc:creator>Sowmi</dc:creator>
		<pubDate>Wed, 23 Sep 2009 03:16:36 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/?p=693#comment-285</guid>
		<description>In my case i need to compare date portion alone from two different table's datetime fields. I used convert in both sides of the comparision and this join itself resulting in 53 % of the overall cost of the query and results in performance degration. How to tune this query and can we use a syntax similar to this 
tab1.col1 between  tab2.col1 and tab2.col1. Please advise asap. thanks a lot.</description>
		<content:encoded><![CDATA[<p>In my case i need to compare date portion alone from two different table&#8217;s datetime fields. I used convert in both sides of the comparision and this join itself resulting in 53 % of the overall cost of the query and results in performance degration. How to tune this query and can we use a syntax similar to this<br />
tab1.col1 between  tab2.col1 and tab2.col1. Please advise asap. thanks a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mrdenny</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/dates-can-easily-be-the-hardest-datatype-to-work-with/#comment-277</link>
		<dc:creator>mrdenny</dc:creator>
		<pubDate>Thu, 17 Sep 2009 23:22:39 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/?p=693#comment-277</guid>
		<description>This is true, BETWEEN is inclusive, so to use BETWEEN correctly you'd want to use

[CODE]WHERE dt BETWEEN ‘01/01/2000′ AND dateadd(ms, -3, ‘01/02/2000′)[/CODE]

Unless you were using SQL 2008's new data types

[CODE]WHERE dt BETWEEN ‘01/01/2000′ AND dateadd(ns, -1, ‘01/02/2000′)[/CODE]</description>
		<content:encoded><![CDATA[<p>This is true, BETWEEN is inclusive, so to use BETWEEN correctly you&#8217;d want to use</p>
<pre>WHERE dt BETWEEN ‘01/01/2000′ AND dateadd(ms, -3, ‘01/02/2000′)</pre>
<p>Unless you were using SQL 2008&#8217;s new data types</p>
<pre>WHERE dt BETWEEN ‘01/01/2000′ AND dateadd(ns, -1, ‘01/02/2000′)</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gmmastros</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/dates-can-easily-be-the-hardest-datatype-to-work-with/#comment-275</link>
		<dc:creator>Gmmastros</dc:creator>
		<pubDate>Thu, 17 Sep 2009 21:29:22 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/?p=693#comment-275</guid>
		<description>Sorry, that should have been:

WHERE dt &#62;= ‘01/01/2000′ AND dt &#60; '01/02/2000'</description>
		<content:encoded><![CDATA[<p>Sorry, that should have been:</p>
<p>WHERE dt &gt;= ‘01/01/2000′ AND dt &lt; &#8216;01/02/2000&#8242;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gmmastros</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/dates-can-easily-be-the-hardest-datatype-to-work-with/#comment-274</link>
		<dc:creator>Gmmastros</dc:creator>
		<pubDate>Thu, 17 Sep 2009 21:27:18 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/?p=693#comment-274</guid>
		<description>[B]WHERE dt BETWEEN ‘01/01/2000′ AND ‘01/02/2000′[/B]

You need to be careful when using between and dates.  That where clause will return rows from the table where the date is 01/02/2000 and the time is midnight.  When working with dates, I prefer to use multiple conditions, like this...

[B]WHERE dt &#62;= ‘01/01/2000′ AND dt = for the start range and &#60; for the end.</description>
		<content:encoded><![CDATA[<p><b>WHERE dt BETWEEN ‘01/01/2000′ AND ‘01/02/2000′</b></p>
<p>You need to be careful when using between and dates.  That where clause will return rows from the table where the date is 01/02/2000 and the time is midnight.  When working with dates, I prefer to use multiple conditions, like this&#8230;</p>
<p><b>WHERE dt &gt;= ‘01/01/2000′ AND dt = for the start range and &lt; for the end.</b></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: My Weekly Bookmarks for September 17th &#124; Brent Ozar - SQL Server DBA</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/dates-can-easily-be-the-hardest-datatype-to-work-with/#comment-273</link>
		<dc:creator>My Weekly Bookmarks for September 17th &#124; Brent Ozar - SQL Server DBA</dc:creator>
		<pubDate>Thu, 17 Sep 2009 21:15:47 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/?p=693#comment-273</guid>
		<description>[...] Dates can easily be the hardest datatype to work with. &#8211; Good post by Denny Cherry about indexing date fields. [...]</description>
		<content:encoded><![CDATA[<p>[...] Dates can easily be the hardest datatype to work with. &#8211; Good post by Denny Cherry about indexing date fields. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BrianTkatch</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/dates-can-easily-be-the-hardest-datatype-to-work-with/#comment-272</link>
		<dc:creator>BrianTkatch</dc:creator>
		<pubDate>Thu, 17 Sep 2009 13:08:04 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/?p=693#comment-272</guid>
		<description>Nice explanation and examples.

I'm bookmarking this one to help explain this concept to others.</description>
		<content:encoded><![CDATA[<p>Nice explanation and examples.</p>
<p>I&#8217;m bookmarking this one to help explain this concept to others.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
<!-- dynamic -->