13,295,051 members (68,154 online)
Rate this:
See more:
Hi frnds,
I have two date column. in that i have to take month and year and combine as follows.
Date1 Date2
01-03-2012 01-05-2013

I need Output as : Mar-2012 - May-2013
Posted 7-Dec-12 4:13am
André Kraak 7-Dec-12 9:20am

What is the data type of the date columns?
itsureshuk 7-Dec-12 9:22am

datetime

Rate this:

## Solution 1

To get Month of the given date:select datename(mm,getdate())
To get Year of given date: select DATENAME(yyyy,GETDATE())

Hope this helps.:)
itsureshuk 7-Dec-12 9:23am

mm format giving numeric month
Rate this:

## Solution 2

Try
`SELECT LEFT(DATENAME(mm,Date1),3) + '-' + CAST(DATEPART(YEAR,Date1) AS VARCHAR) + ' - ' + LEFT(DATENAME(mm,Date2),3) + '-' + CAST(DATEPART(YEAR,Date2) AS VARCHAR),* FROM [YourTable]`
itsureshuk 7-Dec-12 9:36am

thank u,working fine
__TR__ 7-Dec-12 9:37am

You're welcome.

Top Experts
Last 24hrsThis month
 Dave Kreskowiak 90 Richard Deeming 70 F-ES Sitecore 70 _duDE 65 OriginalGriff 65
 OriginalGriff 2,131 Jochen Arndt 1,180 Richard MacCutchan 1,090 ppolymorphe 917 Dave Kreskowiak 915