AngelinaPerez


Hello Guys,

Please could you help me formulate a SELECT statement to output a date in the format (Month, Date Year), eg
October, 07 2007. Thanks.



Re: Select statement to output a date

Andrea Montanari


hi,

please have a look at CONVERT function supported styles and remember date outputs reflects the language of the executing login..

you can so write

SET NOCOUNT ON;
SELECT @@language;
SELECT GETDATE(), CONVERT( varchar(40), GETDATE(), 100);
--<-----
-----------------
us_english
            
----------------------- ----------------------------------------
2007-10-08 01:50:03.310 Oct 8 2007 1:50AM

and having 'english' as my login's language I get that output..

regards







Re: Select statement to output a date

002 007

Thanks Andrea,

I have just tried the line of code above

SELECT GETDATE(), CONVERT( varchar(40), GETDATE(), 100);
The output is as:

08/10/2007 01:54:15 Oct 8 2007 1:54AM


I am just wondering if it is possible to format output date as:


October, 8 2007





Re: Select statement to output a date

Glenn Wilson

To put the punctuation in you might have to break the getdate function up and build the output.






Re: Select statement to output a date

Vidhya Sagar

Hi,

Try the below scripts
1.)
Code Block

SELECT CONVERT( varchar(40), GETDATE(), 107)

Output for above code : Oct 08, 2007


2.) Use this code to get the output as you said
Code Block

select datename(mm,getdate()) + ', ' + convert(varchar(2),datepart(dd,getdate())) + ' ' + convert(varchar(4),datepart(yy,getdate()))

Output for above code : October, 8 2007