 




<?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: 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>
	<lastBuildDate>Tue, 07 May 2013 13:39:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<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><![CDATA[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&#039;m not sure.]]></description>
		<content:encoded><![CDATA[<p>You should be able to do something like this without two much overhead.</p>
<p>[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]</p>
<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><![CDATA[In my case i need to compare date portion alone from two different table&#039;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><![CDATA[This is true, BETWEEN is inclusive, so to use BETWEEN correctly you&#039;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&#039;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>
<p>[CODE]WHERE dt BETWEEN ‘01/01/2000′ AND dateadd(ms, -3, ‘01/02/2000′)[/CODE]</p>
<p>Unless you were using SQL 2008&#8242;s new data types</p>
<p>[CODE]WHERE dt BETWEEN ‘01/01/2000′ AND dateadd(ns, -1, ‘01/02/2000′)[/CODE]</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-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><![CDATA[Sorry, that should have been:

WHERE dt &gt;= ‘01/01/2000′ AND dt &lt; &#039;01/02/2000&#039;]]></description>
		<content:encoded><![CDATA[<p>Sorry, that should have been:</p>
<p>WHERE dt &gt;= ‘01/01/2000′ AND dt &lt; &#8217;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><![CDATA[[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 &gt;= ‘01/01/2000′ AND dt = for the start range and &lt; 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.</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><![CDATA[Nice explanation and examples.

I&#039;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>
