﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server 2008 - General  / Date format / 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>Sat, 25 May 2013 17:21:55 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Date format</title><link>http://www.sqlservercentral.com/Forums/Topic1398230-391-1.aspx</link><description>There's always alternate ways of formatting a date.  Whether you'd want to use them is another story.[code="sql"]DECLARE @product_name VARCHAR(20) = 'Vehicles'     ,@expiry_date DATETIME = '2012-09-10'SELECT STUFF(RIGHT(CONVERT(VARCHAR(12), @expiry_date,107), 9), 1, 0    ,'Product : ' + @product_name + ' (Expires ' + DATENAME(MM, @expiry_date)) + ')'[/code]</description><pubDate>Wed, 19 Dec 2012 18:11:24 GMT</pubDate><dc:creator>dwain.c</dc:creator></item><item><title>RE: Date format</title><link>http://www.sqlservercentral.com/Forums/Topic1398230-391-1.aspx</link><description>Or this:[code="sql"]DECLARE @Expiry_Date DATETIME = '2012-12-25 00:00:01.003', @Prod VARCHAR(MAX), @Product_Name VARCHAR(10) = 'Vehicles'SET @Prod= 'Product: ' + @Product_name + ' (Expires ' + STUFF(CONVERT(VARCHAR(12), @Expiry_Date, 107), 1, 3, DATENAME(MM, @Expiry_Date)) + ')'SELECT @Prod[/code]</description><pubDate>Wed, 19 Dec 2012 09:12:11 GMT</pubDate><dc:creator>Lynn Pettis</dc:creator></item><item><title>RE: Date format</title><link>http://www.sqlservercentral.com/Forums/Topic1398230-391-1.aspx</link><description>How about this:[code="sql"]DECLARE @Expiry_Date DATETIME = '2012-12-25 00:00:01.003';SELECT DATENAME(MONTH, @Expiry_Date) + ' ' + DATENAME(DAY, @Expiry_Date) + ', ' + DATENAME(YEAR, @Expiry_Date);[/code]</description><pubDate>Wed, 19 Dec 2012 08:50:01 GMT</pubDate><dc:creator>GSquared</dc:creator></item><item><title>RE: Date format</title><link>http://www.sqlservercentral.com/Forums/Topic1398230-391-1.aspx</link><description>[code="sql"]DECLARE @Expiry_Date DATETIME = '2012-12-25 00:00:01.003', @Prod VARCHAR(MAX), @Product_Name VARCHAR(10) = 'Vehicles'SET @Prod=@Product_name + RTRIM(@Product_name)+ ' (Expires '+RTRIM(DATENAME(MM, @Expiry_Date ) + RIGHT(CONVERT(VARCHAR(12), @Expiry_Date ,107),9))+ ')'SELECT @Prod[/code]Output isVehiclesVehicles (Expires December 25, 2012)</description><pubDate>Wed, 19 Dec 2012 08:43:34 GMT</pubDate><dc:creator>anthony.green</dc:creator></item><item><title>RE: Date format</title><link>http://www.sqlservercentral.com/Forums/Topic1398230-391-1.aspx</link><description>i want to append the expiry date to a variable like below..DECLARE @Expiry_Date DATETIME = '2012-12-25 00:00:01.003'SET @Prod=@Product_name + RTRIM(@Product_name) +SELECT '(Expires '+RTRIM(DATENAME(MM, @Expiry_Date ) + RIGHT(CONVERT(VARCHAR(12), @Expiry_Date ,107),9))+ ')'but its not working...</description><pubDate>Wed, 19 Dec 2012 08:40:27 GMT</pubDate><dc:creator>Minnu</dc:creator></item><item><title>RE: Date format</title><link>http://www.sqlservercentral.com/Forums/Topic1398230-391-1.aspx</link><description>DECLARE @Expiry_Date DATETIME = '2012-12-25 00:00:01.003'SELECT '(Expires '+RTRIM(DATENAME(MM, @Expiry_Date ) + RIGHT(CONVERT(VARCHAR(12), @Expiry_Date ,107),9))+ ')'Gives me an output of (Expires December 25, 2012)</description><pubDate>Wed, 19 Dec 2012 08:29:54 GMT</pubDate><dc:creator>anthony.green</dc:creator></item><item><title>RE: Date format</title><link>http://www.sqlservercentral.com/Forums/Topic1398230-391-1.aspx</link><description>Expiry_date  Format is : DATETIME</description><pubDate>Wed, 19 Dec 2012 08:27:38 GMT</pubDate><dc:creator>Minnu</dc:creator></item><item><title>RE: Date format</title><link>http://www.sqlservercentral.com/Forums/Topic1398230-391-1.aspx</link><description>Well something is wrong as I run it I get the , in the output between the date and year which is what the convert 107 does.What is the data type of the parameter @expiry_date</description><pubDate>Wed, 19 Dec 2012 08:24:31 GMT</pubDate><dc:creator>anthony.green</dc:creator></item><item><title>RE: Date format</title><link>http://www.sqlservercentral.com/Forums/Topic1398230-391-1.aspx</link><description>[b]First Query[/b]SET @Prod=@Product_name + RTRIM(@Product_name) + ' (Expires ' +RTRIM(DATENAME(MM, @expriry_date ) + RIGHT(CONVERT(VARCHAR(12), @expriry_date ,107),9))+ ')' +CHAR(10) Result is : Product : Vehicles (Expires September 30 2012)[b]Second Query[/b]SELECT '(Expires '+RTRIM(DATENAME(MM, GETDATE()) +','+ RIGHT(CONVERT(VARCHAR(12), GETDATE() ,107),9))+ ')'Result is : Product : Vehicles (Expires September, 30 2012)--I want comma after September 30.Eg: September 30, 2012</description><pubDate>Wed, 19 Dec 2012 08:21:29 GMT</pubDate><dc:creator>Minnu</dc:creator></item><item><title>RE: Date format</title><link>http://www.sqlservercentral.com/Forums/Topic1398230-391-1.aspx</link><description>then do what you where doing in the first place, this is how it outputsSELECT '(Expires '+RTRIM(DATENAME(MM, GETDATE() ) + RIGHT(CONVERT(VARCHAR(12), GETDATE() ,107),9))+ ')'(Expires December 19, 2012)</description><pubDate>Wed, 19 Dec 2012 08:17:11 GMT</pubDate><dc:creator>anthony.green</dc:creator></item><item><title>RE: Date format</title><link>http://www.sqlservercentral.com/Forums/Topic1398230-391-1.aspx</link><description>Hi Anthony,Small change in my requirement, I want only one comma after the Date.Product : Vehicles (Expires September 30, 2012)</description><pubDate>Wed, 19 Dec 2012 08:15:12 GMT</pubDate><dc:creator>Minnu</dc:creator></item><item><title>RE: Date format</title><link>http://www.sqlservercentral.com/Forums/Topic1398230-391-1.aspx</link><description>You want to modify the output to one which doesnt happen when you convert a date so you have to manually tell it the format which is why you need to manually put in the extra comma using ','</description><pubDate>Wed, 19 Dec 2012 02:34:27 GMT</pubDate><dc:creator>anthony.green</dc:creator></item><item><title>RE: Date format</title><link>http://www.sqlservercentral.com/Forums/Topic1398230-391-1.aspx</link><description>Thank U anthony,Its working...Is there any alternate syntax/query to get the above result.i mean without using above code i want to generate the same output...</description><pubDate>Wed, 19 Dec 2012 02:32:27 GMT</pubDate><dc:creator>Minnu</dc:creator></item><item><title>RE: Date format</title><link>http://www.sqlservercentral.com/Forums/Topic1398230-391-1.aspx</link><description>SELECT '(Expires '+RTRIM(DATENAME(MM, GETDATE()) +','+ RIGHT(CONVERT(VARCHAR(12), GETDATE() ,107),9))+ ')'Gives (Expires December, 19, 2012)</description><pubDate>Wed, 19 Dec 2012 02:06:56 GMT</pubDate><dc:creator>anthony.green</dc:creator></item><item><title>Date format</title><link>http://www.sqlservercentral.com/Forums/Topic1398230-391-1.aspx</link><description>Hi Team,using below query, am assigning a Product_name and its expriry_date to a variable Prod[b] SET @Prod=@Product_name + RTRIM(@Product_name) + ' (Expires '   +RTRIM(DATENAME(MM, @expriry_date ) + RIGHT(CONVERT(VARCHAR(12), @expriry_date ,107),9))+ ')' +CHAR(10) [/b]but am getting out put as below[b]Product : Vehicles (Expires September 30 2012)[/b]i want out put like below (comma after month)[b]Product : Vehicles (Expires September 30, 2012)[/b]Please help</description><pubDate>Wed, 19 Dec 2012 01:37:10 GMT</pubDate><dc:creator>Minnu</dc:creator></item></channel></rss>