Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Month number to Month name

I'm looking for a way to convert Month numbers to their three-letter names.

Currently, the Month field is loaded by Month(OrderDate) where OrderDate is a Date. However, inside QV, the months show up as numbers from 1-12 and I need them to say Jan, Feb, ...

So far on the forums I've only seen how to convert from the Names to the numbers but not back. Is there a way to do this?

Thanks

26 Replies
johnw
Champion III
Champion III

It might be more flexible to preserve the numeric format as well.

dual(pick(OrderDate,'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'),OrderDate)

Sorting could be done in numeric order, you could subtract months, and so on.

Not applicable
Author

Thank you - your solution was perfect!

rotero
Creator
Creator

this is what im looking for, a quick fix in case the value of month is in NUMERIC value that is not from a date function. This is common if the source data is in csv or xls file.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

An easy way to get a proper QV month dual from a month number is:

=month(MakeDate(2000,numericMonthField))

It doesn't matter what year you use in the Makedate() function.

-Rob

Not applicable
Author

Begineers can use if codition.

Hear is the code:

When Month is loaded as number only.

if(Month=1,'Jan',

     if(Month=2,'Feb',

          if(Month=3,'Mar',

               if(Month=4,'Apr',

                        if(Month=5,'May',

                              if(Month=6,'June',

                                   if(Month=7,'Jul',

                                        if(Month=8,'Aug',

                                             if(Month=9,'Sep',

                                                  if(Month=10,'Oct',

                                                       if(Month=11,'Nov',

                                                            if(Month=12,'Dec')))))))))))) as Month,

brooksc57
Creator
Creator

Most of the scripts were for tables.

yours worked perfectly for this instance...of front end variables

For vCursorMonth = (vMonthFrom) to (vMonthTo)

Let vcmm = PICK($(vCursorMonth),'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');

José_Espinoza
Partner - Contributor III
Partner - Contributor III

This works great when you need Month as both numbers and letters, so you can work with both dimensions (ie. [Month] and [MonthNumber]).

Thanks a lot.