We help IT Professionals succeed at work.
Get Started

Date Functions, How to convert 'datetime' field to text decription('December 2012')  in SQl Server Developer 14?

86 Views
Last Modified: 2017-12-31
I've looked thru the 'Date and Time Functions' in SSMS under the 'Functions'/System Functions but I don't have any documentation.

I am pulling data from a file that I want to sort and group on the Year and Month of the Payment Date.  The payment date is defined at 'datetime'.  Payments from the same year and month should be grouped and summarized into a 'Collection Period' line on the report.

I was able to used the Year function to extract the 4 digit year (for example:(2002)  and I was able to use the 'Month' function to pull the month (6) but I can't make the leap to what the user wants.  On the generated report the user wants to see the 'Collection Period' in text (December 2012, November 2012 etc..).  They also want the collection period sorted in ascending order.  December 2012 will be followed by January 2013 etc..

Any payments for dates 12/1/12 thru 12/31/12 would be grouped, summarized and show on the report as December 2012.

 Any November payment dates dates would be shown as November 2012 etc..

Is there any way within SQL to convert from the original 'PaymentDate', datetime field (12/2/12, 12/3/12, 12/15/12, 12/22/12) to the corresponding text description (December 2012)?
Comment
Watch Question
Analyst Assistant
CERTIFIED EXPERT
Distinguished Expert 2020
Commented:
This problem has been solved!
Unlock 4 Answers and 7 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE