user1086159
user1086159

Reputation: 1055

SQL Date to Text

I am running the below query and would like to convert the column 'JVDATE' into just showing the month.

Query:

SELECT 
   FISCALYEAR, JVDATE, ACCOUNTNUMBER, ACCOUNTDESCRIPTION, 
   CATEGORY, POSTINGTYPE, AUDITTRAIL, 
   ORIGDOCNUMBER, ORIGDEBIT, ORIGCREDIT, ORIGNETAMOUNT
FROM 
   SRVS.dbo.vw_GLTrialBalancev2010

When I run the query I get .....

enter image description here

What is the easiest way to do this?

Many thanks,

Upvotes: 0

Views: 44

Answers (1)

Damien_The_Unbeliever
Damien_The_Unbeliever

Reputation: 239684

Do you maybe want DATENAME?

SELECT ..., DATENAME(Month,JVDate) as Month,....

(Or, if you want it as a numeric value, as per @Amit's answer, I'd usually go with the DATEPART function, since it applies to all component parts rather than having to find specific functions for each component)

Upvotes: 2

Related Questions