<?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: SQL How to split out the Time from a DateTime col then use that in a WHERE Clause</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/sql-how-to-split-out-the-time-from-a-datetime-col-then-use-that-in-a-where-clause/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-how-to-split-out-the-time-from-a-datetime-col-then-use-that-in-a-where-clause/</link>
	<description></description>
	<lastBuildDate>Thu, 20 Jun 2013 01:19:26 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: walrum</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-how-to-split-out-the-time-from-a-datetime-col-then-use-that-in-a-where-clause/#comment-101969</link>
		<dc:creator>walrum</dc:creator>
		<pubDate>Tue, 24 Jan 2012 00:33:56 +0000</pubDate>
		<guid isPermaLink="false">#comment-101969</guid>
		<description><![CDATA[I believe that SELECT  DATEPART(HH, GETDATE()) the best answer.

in other words following your sample:

WHERE DATEPART(HH, StartTime )&gt;= ‘15′ AND DATEPART(HH, EndTime) &lt;= ‘16′]]></description>
		<content:encoded><![CDATA[<p>I believe that SELECT  DATEPART(HH, GETDATE()) the best answer.</p>
<p>in other words following your sample:</p>
<p>WHERE DATEPART(HH, StartTime )&gt;= ‘15′ AND DATEPART(HH, EndTime) &lt;= ‘16′</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-how-to-split-out-the-time-from-a-datetime-col-then-use-that-in-a-where-clause/#comment-101262</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Thu, 05 Jan 2012 02:06:48 +0000</pubDate>
		<guid isPermaLink="false">#comment-101262</guid>
		<description><![CDATA[&lt;i&gt;WHERE StartTime &gt;= ‘15:00:00′ AND EndTime &lt;= ‘16:00:00′&lt;/i&gt;

If those are DateTime data types, can&#039;t you do this?

&lt;pre&gt;WHERE CONVERT(time(0),StartTime) &gt;= ‘15:00:00′ AND CONVERT(time(0),EndTime) &lt;= ‘16:00:00′&lt;/pre&gt;

Or am I misunderstanding?

Tom]]></description>
		<content:encoded><![CDATA[<p><i>WHERE StartTime &gt;= ‘15:00:00′ AND EndTime &lt;= ‘16:00:00′</i></p>
<p>If those are DateTime data types, can&#8217;t you do this?</p>
<pre>WHERE CONVERT(time(0),StartTime) &gt;= ‘15:00:00′ AND CONVERT(time(0),EndTime) &lt;= ‘16:00:00′</pre>
<p>Or am I misunderstanding?</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: darraca</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-how-to-split-out-the-time-from-a-datetime-col-then-use-that-in-a-where-clause/#comment-101245</link>
		<dc:creator>darraca</dc:creator>
		<pubDate>Wed, 04 Jan 2012 15:43:05 +0000</pubDate>
		<guid isPermaLink="false">#comment-101245</guid>
		<description><![CDATA[Hi, sorry I&#039;ve managed to sort this now.

The reason I needed the time splitting out was because I was working on an assignment to create a room booking project in vb.net.  The database is stored in SQL Server and I had to use a table called Bookings which had the following 3 columns:
BookDate
StartTime
EndTime

I wanted to create a query that brought back any rooms that had been booked for a date contained in the BookDate column that fell between the time that is stored between the StartTime and EndTime columns.  This is the reason why I was only interested in the Time part of the StartTime and EndTime columns.

I sorted this out by making sure that the date in the StartTime and EndTime columns was 1 Jan 1900, followed by the time. That way I could write the query as something similar to the following:

StartTime                            EndTime
1900-01-01 15:30:00       1900-01-01 16:00:00

WHERE StartTime &gt;= &#039;15:00:00&#039; AND EndTime &lt;= &#039;16:00:00&#039;

Thanks anyway :)]]></description>
		<content:encoded><![CDATA[<p>Hi, sorry I&#8217;ve managed to sort this now.</p>
<p>The reason I needed the time splitting out was because I was working on an assignment to create a room booking project in vb.net.  The database is stored in SQL Server and I had to use a table called Bookings which had the following 3 columns:<br />
BookDate<br />
StartTime<br />
EndTime</p>
<p>I wanted to create a query that brought back any rooms that had been booked for a date contained in the BookDate column that fell between the time that is stored between the StartTime and EndTime columns.  This is the reason why I was only interested in the Time part of the StartTime and EndTime columns.</p>
<p>I sorted this out by making sure that the date in the StartTime and EndTime columns was 1 Jan 1900, followed by the time. That way I could write the query as something similar to the following:</p>
<p>StartTime                            EndTime<br />
1900-01-01 15:30:00       1900-01-01 16:00:00</p>
<p>WHERE StartTime &gt;= &#8217;15:00:00&#8242; AND EndTime &lt;= &#8217;16:00:00&#8242;</p>
<p>Thanks anyway <img src='http://itknowledgeexchange.techtarget.com/itanswers/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: carlosdl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-how-to-split-out-the-time-from-a-datetime-col-then-use-that-in-a-where-clause/#comment-101239</link>
		<dc:creator>carlosdl</dc:creator>
		<pubDate>Wed, 04 Jan 2012 14:15:20 +0000</pubDate>
		<guid isPermaLink="false">#comment-101239</guid>
		<description><![CDATA[I&#039;m not sure to understand why you need to split the time to use it in the WHERE clause.

Maybe these functions can help you: &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms174395.aspx&quot;&gt;DATENAME&lt;/a&gt;, &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms174420.aspx&quot;&gt;DATEPART&lt;/a&gt;.

It would be a good idea posting some example data, with the corresponding expected results.]]></description>
		<content:encoded><![CDATA[<p>I&#8217;m not sure to understand why you need to split the time to use it in the WHERE clause.</p>
<p>Maybe these functions can help you: <a href="http://msdn.microsoft.com/en-us/library/ms174395.aspx">DATENAME</a>, <a href="http://msdn.microsoft.com/en-us/library/ms174420.aspx">DATEPART</a>.</p>
<p>It would be a good idea posting some example data, with the corresponding expected results.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 6/9 queries in 0.012 seconds using memcached
Object Caching 314/317 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-06-20 02:46:32 -->