 




<?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: T-sql date question</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/t-sql-date-question/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/t-sql-date-question/</link>
	<description></description>
	<lastBuildDate>Wed, 22 May 2013 02:14:48 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: mrdenny</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/t-sql-date-question/#comment-56407</link>
		<dc:creator>mrdenny</dc:creator>
		<pubDate>Sat, 13 Sep 2008 22:50:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-56407</guid>
		<description><![CDATA[Use the convert function.

&lt;pre&gt;select convert(varchar(10), &#039;2005-09-14 09:49:13.873&#039;, 101)&lt;/pre&gt;]]></description>
		<content:encoded><![CDATA[<p>Use the convert function.</p>
<pre>select convert(varchar(10), '2005-09-14 09:49:13.873', 101)</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: lechuck</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/t-sql-date-question/#comment-40673</link>
		<dc:creator>lechuck</dc:creator>
		<pubDate>Fri, 16 Sep 2005 06:44:14 +0000</pubDate>
		<guid isPermaLink="false">#comment-40673</guid>
		<description><![CDATA[At first I went for the same solution as first mentioned by servee, but for some reason, my SQL Server did not return the needed.

I doubt, that the solution by chicotellez would work, unless your database runs certain languages, that by default removes the hh.mm from the smalldatetime.
- hh.mm is normally part of the smalldatetime!
Besides - creating an entire new table just to solve this problem seems a bit like shooting birds with canons!

Since the solution by servee didn&#039;t work for me, I worked out this solution in stead... Not an optimal solution at all - I admit to that - but it works:

declare @date as datetime, @strDate as varchar(10) 
set @date = getdate()
set @strDate = cast(day(@date) as varchar) +&#039;-&#039;+ cast(month(@date) as varchar) +&#039;-&#039;+ cast(year(@date) as varchar)
select cast(@strDate as datetime)

Hope someone has a better solution! (?)

Good luck
Jacob]]></description>
		<content:encoded><![CDATA[<p>At first I went for the same solution as first mentioned by servee, but for some reason, my SQL Server did not return the needed.</p>
<p>I doubt, that the solution by chicotellez would work, unless your database runs certain languages, that by default removes the hh.mm from the smalldatetime.<br />
- hh.mm is normally part of the smalldatetime!<br />
Besides &#8211; creating an entire new table just to solve this problem seems a bit like shooting birds with canons!</p>
<p>Since the solution by servee didn&#8217;t work for me, I worked out this solution in stead&#8230; Not an optimal solution at all &#8211; I admit to that &#8211; but it works:</p>
<p>declare @date as datetime, @strDate as varchar(10)<br />
set @date = getdate()<br />
set @strDate = cast(day(@date) as varchar) +&#8217;-'+ cast(month(@date) as varchar) +&#8217;-'+ cast(year(@date) as varchar)<br />
select cast(@strDate as datetime)</p>
<p>Hope someone has a better solution! (?)</p>
<p>Good luck<br />
Jacob</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chicotellez</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/t-sql-date-question/#comment-40674</link>
		<dc:creator>chicotellez</dc:creator>
		<pubDate>Thu, 15 Sep 2005 15:36:03 +0000</pubDate>
		<guid isPermaLink="false">#comment-40674</guid>
		<description><![CDATA[try this.
sql server 2000

/* Creating a Test Table */
Create Table MyDateTest99
(
 DateColumn smalldatetime
)
go


/* Inserting the test value into the table */
/*insert into MyDateTest99 values (&#039;2005-09-15 00:00:00&#039;) */
insert into MyDateTest99 select convert (varchar(10),&#039;2005-09-15 01:03:22&#039;,120)

go


/* Selecting the result */
select DateColumn from MyDateTest99
go


/* Performing Cleanup */
drop table MyDateTest99
go


]]></description>
		<content:encoded><![CDATA[<p>try this.<br />
sql server 2000</p>
<p>/* Creating a Test Table */<br />
Create Table MyDateTest99<br />
(<br />
 DateColumn smalldatetime<br />
)<br />
go</p>
<p>/* Inserting the test value into the table */<br />
/*insert into MyDateTest99 values (&#8217;2005-09-15 00:00:00&#8242;) */<br />
insert into MyDateTest99 select convert (varchar(10),&#8217;2005-09-15 01:03:22&#8242;,120)</p>
<p>go</p>
<p>/* Selecting the result */<br />
select DateColumn from MyDateTest99<br />
go</p>
<p>/* Performing Cleanup */<br />
drop table MyDateTest99<br />
go</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 296/299 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-22 02:27:13 -->