﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Administration / SQL Server 7,2000  / Select Datepart / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sun, 19 May 2013 12:11:19 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Select Datepart</title><link>http://www.sqlservercentral.com/Forums/Topic288619-5-1.aspx</link><description>Of course, I never noticed the "Or is there some other way to do it" portion of the post 8-O</description><pubDate>Mon, 19 Jun 2006 15:29:00 GMT</pubDate><dc:creator>brendt hess</dc:creator></item><item><title>RE: Select Datepart</title><link>http://www.sqlservercentral.com/Forums/Topic288619-5-1.aspx</link><description>Perhaps, but the questioner specifically requested a method using DatePart.  I use this when generating a YYYYMMDDHHNN strings, in preference to stripping formatting out of a CONVERTed datetime, because it is far more readable.</description><pubDate>Mon, 19 Jun 2006 15:28:00 GMT</pubDate><dc:creator>brendt hess</dc:creator></item><item><title>RE: Select Datepart</title><link>http://www.sqlservercentral.com/Forums/Topic288619-5-1.aspx</link><description>&lt;P&gt;I just realized that I pasted the wrong section into my post.&lt;/P&gt;&lt;P&gt;This returns the same result as Brendt's DatePart/Cast example, but with less function calls:&lt;/P&gt;&lt;P&gt;SELECT CONVERT(varchar,GETDATE(),112)&lt;/P&gt;</description><pubDate>Mon, 19 Jun 2006 14:53:00 GMT</pubDate><dc:creator>John Rowan</dc:creator></item><item><title>RE: Select Datepart</title><link>http://www.sqlservercentral.com/Forums/Topic288619-5-1.aspx</link><description>&lt;P&gt;That worked great, thanks!&lt;/P&gt;</description><pubDate>Mon, 19 Jun 2006 14:41:00 GMT</pubDate><dc:creator>Nali</dc:creator></item><item><title>RE: Select Datepart</title><link>http://www.sqlservercentral.com/Forums/Topic288619-5-1.aspx</link><description>Yes, there is.  This code will do what you need:SELECT	Cast(Datepart(yyyy, GetDate()) AS char(4)) +	Right('0' + Cast(DatePart(mm, GetDate()) AS Varchar(2)), 2) +	Right('0' + Cast(DatePart(dd, GetDate()) AS Varchar(2)), 2)</description><pubDate>Mon, 19 Jun 2006 14:38:00 GMT</pubDate><dc:creator>brendt hess</dc:creator></item><item><title>RE: Select Datepart</title><link>http://www.sqlservercentral.com/Forums/Topic288619-5-1.aspx</link><description>print convert(varchar,@datetime,112)</description><pubDate>Mon, 19 Jun 2006 14:22:00 GMT</pubDate><dc:creator>John Rowan</dc:creator></item><item><title>Select Datepart</title><link>http://www.sqlservercentral.com/Forums/Topic288619-5-1.aspx</link><description>&lt;P&gt;Is there a way for me to use the Datepart function so that it would return today's date as:&lt;/P&gt;&lt;P&gt;20060619&lt;/P&gt;&lt;P&gt;Or is there another way I can do it?&lt;/P&gt;&lt;P&gt;The below didn't quite get me what I needed.&lt;/P&gt;&lt;P&gt;SELECT DATEPART(YYYY, GETDATE()), DATEPART(MM,GETDATE()) , DATEPART(DD, GETDATE())&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description><pubDate>Mon, 19 Jun 2006 14:12:00 GMT</pubDate><dc:creator>Nali</dc:creator></item></channel></rss>