<?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: Removing time from SQL datetime</title>
	<atom:link href="http://www.thycotic.com/removing-time-from-sql-datetime/feed" rel="self" type="application/rss+xml" />
	<link>http://www.thycotic.com/removing-time-from-sql-datetime</link>
	<description></description>
	<lastBuildDate>Thu, 11 Mar 2010 16:14:45 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: shekhar R. gurav</title>
		<link>http://www.thycotic.com/removing-time-from-sql-datetime/comment-page-1#comment-3913</link>
		<dc:creator>shekhar R. gurav</dc:creator>
		<pubDate>Thu, 19 Nov 2009 09:37:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.thycotic.com/?p=372#comment-3913</guid>
		<description>sir,

i saved all my dates in MM/dd/yyyy in ms-access database. in front end i show in dd/MM/yyyy format.

For my update query i am taking date from different windows froms which is like 
#13/07/2009# but at database level it will it is #13/07/2009 1:12:09 AM#   

so it compare date as well as time . but i don&#039;t want compare my date with time also...

so what i do ? 

it is for Ms-acess...</description>
		<content:encoded><![CDATA[<p>sir,</p>
<p>i saved all my dates in MM/dd/yyyy in ms-access database. in front end i show in dd/MM/yyyy format.</p>
<p>For my update query i am taking date from different windows froms which is like<br />
#13/07/2009# but at database level it will it is #13/07/2009 1:12:09 AM#   </p>
<p>so it compare date as well as time . but i don&#8217;t want compare my date with time also&#8230;</p>
<p>so what i do ? </p>
<p>it is for Ms-acess&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://www.thycotic.com/removing-time-from-sql-datetime/comment-page-1#comment-3872</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Tue, 11 Aug 2009 08:41:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.thycotic.com/?p=372#comment-3872</guid>
		<description>There is more powerful way to round the datetime to any period.

declare @a datetime
set @a = getdate()

select 
  @a [full], 
  dateadd(minute, datediff(minute, &#039;&#039;, @a), &#039;&#039;) [minute], 
  dateadd(day,    datediff(day,    &#039;&#039;, @a), &#039;&#039;) [day], 
  dateadd(month,  datediff(month,  &#039;&#039;, @a), &#039;&#039;) [month], 
  dateadd(year,   datediff(year,   &#039;&#039;, @a), &#039;&#039;) [year]</description>
		<content:encoded><![CDATA[<p>There is more powerful way to round the datetime to any period.</p>
<p>declare @a datetime<br />
set @a = getdate()</p>
<p>select<br />
  @a [full],<br />
  dateadd(minute, datediff(minute, &#8221;, @a), &#8221;) [minute],<br />
  dateadd(day,    datediff(day,    &#8221;, @a), &#8221;) [day],<br />
  dateadd(month,  datediff(month,  &#8221;, @a), &#8221;) [month],<br />
  dateadd(year,   datediff(year,   &#8221;, @a), &#8221;) [year]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin</title>
		<link>http://www.thycotic.com/removing-time-from-sql-datetime/comment-page-1#comment-3866</link>
		<dc:creator>Kevin</dc:creator>
		<pubDate>Sun, 09 Aug 2009 15:16:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.thycotic.com/?p=372#comment-3866</guid>
		<description>Here&#039;s a challenge:

Can anyone come up with a set based way to remove the DATE and keep only the TIME that will work with SQL 2005?</description>
		<content:encoded><![CDATA[<p>Here&#8217;s a challenge:</p>
<p>Can anyone come up with a set based way to remove the DATE and keep only the TIME that will work with SQL 2005?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin</title>
		<link>http://www.thycotic.com/removing-time-from-sql-datetime/comment-page-1#comment-3865</link>
		<dc:creator>Kevin</dc:creator>
		<pubDate>Sun, 09 Aug 2009 14:34:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.thycotic.com/?p=372#comment-3865</guid>
		<description>Hi Aaron,

Thanks for the excellent tip! However, I did a little bit of performance testing myself and found the cast to FLOAT is just ever so slightly faster -- most of the time :-)

Using the DATEDIFF operation over about 2,000,000 rows took 00:00:12.626. Using the FLOAT operation is 00:00:12.601. This was an average of 10 times.

In some circumstances your operation was faster.

One other thing to note is I am using a 64-bit SKU - some operations (like float arithmetic) can be faster on x64.

Here was the basic test script:

CREATE TABLE ##Test
(
	Foo DATETIME
)

GO

DECLARE @tracker INT
SET @tracker = 0

WHILE(@tracker &lt; 2000000)
BEGIN
	INSERT INTO ##Test SELECT GETDATE()
	SET @tracker = @tracker + 1
END

GO

SELECT DATEADD(DAY, 1, DATEDIFF(DAY, 0, Foo)) FROM ##Test
SELECT CAST(FLOOR(CAST(Foo AS FLOAT)) AS DATETIME) FROM ##Test

DROP TABLE ##Test</description>
		<content:encoded><![CDATA[<p>Hi Aaron,</p>
<p>Thanks for the excellent tip! However, I did a little bit of performance testing myself and found the cast to FLOAT is just ever so slightly faster &#8212; most of the time <img src='http://www.thycotic.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Using the DATEDIFF operation over about 2,000,000 rows took 00:00:12.626. Using the FLOAT operation is 00:00:12.601. This was an average of 10 times.</p>
<p>In some circumstances your operation was faster.</p>
<p>One other thing to note is I am using a 64-bit SKU &#8211; some operations (like float arithmetic) can be faster on x64.</p>
<p>Here was the basic test script:</p>
<p>CREATE TABLE ##Test<br />
(<br />
	Foo DATETIME<br />
)</p>
<p>GO</p>
<p>DECLARE @tracker INT<br />
SET @tracker = 0</p>
<p>WHILE(@tracker &lt; 2000000)<br />
BEGIN<br />
	INSERT INTO ##Test SELECT GETDATE()<br />
	SET @tracker = @tracker + 1<br />
END</p>
<p>GO</p>
<p>SELECT DATEADD(DAY, 1, DATEDIFF(DAY, 0, Foo)) FROM ##Test<br />
SELECT CAST(FLOOR(CAST(Foo AS FLOAT)) AS DATETIME) FROM ##Test</p>
<p>DROP TABLE ##Test</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron Bertrand</title>
		<link>http://www.thycotic.com/removing-time-from-sql-datetime/comment-page-1#comment-3864</link>
		<dc:creator>Aaron Bertrand</dc:creator>
		<pubDate>Fri, 07 Aug 2009 21:41:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.thycotic.com/?p=372#comment-3864</guid>
		<description>I believe keeping it as datetime is even faster.  I remember doing performance tests on huge loops but I don&#039;t recall if I ever published the results.

SELECT DATEADD(DAY, 0, DATEDIFF(DAY, 0, CURRENT_TIMESTAMP));

Of course if you are assigning the value to a column or a DATETIME/SMALLDATETIME variable, you can avoid one operation:

DECLARE @d SMALLDATETIME;
SET @d = DATEDIFF(DAY, 0, CURRENT_TIMESTAMP);
SELECT @d;</description>
		<content:encoded><![CDATA[<p>I believe keeping it as datetime is even faster.  I remember doing performance tests on huge loops but I don&#8217;t recall if I ever published the results.</p>
<p>SELECT DATEADD(DAY, 0, DATEDIFF(DAY, 0, CURRENT_TIMESTAMP));</p>
<p>Of course if you are assigning the value to a column or a DATETIME/SMALLDATETIME variable, you can avoid one operation:</p>
<p>DECLARE @d SMALLDATETIME;<br />
SET @d = DATEDIFF(DAY, 0, CURRENT_TIMESTAMP);<br />
SELECT @d;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dew Drop &#8211; August 7, 2009 &#124; Alvin Ashcraft's Morning Dew</title>
		<link>http://www.thycotic.com/removing-time-from-sql-datetime/comment-page-1#comment-3863</link>
		<dc:creator>Dew Drop &#8211; August 7, 2009 &#124; Alvin Ashcraft's Morning Dew</dc:creator>
		<pubDate>Fri, 07 Aug 2009 12:12:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.thycotic.com/?p=372#comment-3863</guid>
		<description>[...] Removing time from SQL datetime (Kevin Jones) [...]</description>
		<content:encoded><![CDATA[<p>[...] Removing time from SQL datetime (Kevin Jones) [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
