Friday, March 23, 2012

Month Name rather than Month Integer

Hi,
I am using the following query
SELECT FirstName AS FirstName, LastName AS LastName, COUNT(*) AS
NoOfOrders,
MONTH(CreatedDate) AS Order_Month
FROM Customer_Info
I want the Order_Month field to conain month name & not integers... Is there
a way that I can do this in this query itself ? & how?
pmudYes, use DateName() function, as in:
Select DateName(month, getdate())
Just take left( , 3) of that to get abbreviation
Select Left(DateName(month, getdate()),3)
"pmud" wrote:

> Hi,
> I am using the following query
> SELECT FirstName AS FirstName, LastName AS LastName, COUNT(*) AS
> NoOfOrders,
> MONTH(CreatedDate) AS Order_Month
> FROM Customer_Info
> I want the Order_Month field to conain month name & not integers... Is the
re
> a way that I can do this in this query itself ? & how?
> --
> pmud|||--BEGIN PGP SIGNED MESSAGE--
Hash: SHA1
Try:
print convert(char(3),getdate(),9)
To get the 1st 3 chars of the month name.
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
--BEGIN PGP SIGNATURE--
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/ AwUBQjYmYYechKqOuFEgEQI6cQCaAqePHwzETSIU
H+001wpBY6rP0TsAoIc8
h0Bj/kYzw1k3NP+lO7DvySQ2
=JHMo
--END PGP SIGNATURE--
pmud wrote:
> Hi,
> I am using the following query
> SELECT FirstName AS FirstName, LastName AS LastName, COUNT(*) AS
> NoOfOrders,
> MONTH(CreatedDate) AS Order_Month
> FROM Customer_Info
> I want the Order_Month field to conain month name & not integers... Is the
re
> a way that I can do this in this query itself ? & how?
>|||Thanks CBretana, That helped.. :))
"CBretana" wrote:
> Yes, use DateName() function, as in:
> Select DateName(month, getdate())
> Just take left( , 3) of that to get abbreviation
> Select Left(DateName(month, getdate()),3)
>
> "pmud" wrote:
>

No comments:

Post a Comment