I have 2 INTEGER
columns like the following:
Month Year
----- -----
5 2011
Is there any way to convert that to a single column VARCHAR
like this: May-2011
I have 2 INTEGER
columns like the following:
Month Year
----- -----
5 2011
Is there any way to convert that to a single column VARCHAR
like this: May-2011
I realize this question is pretty old, but there's a way that is a lot simpler than any of the options listed here (in my opinion) -- a combination of some date math and the
VARCHAR_FORMAR()
function:I don't know of an easy way to do this since you don't have a date object (ie its not like youre finding the month of a timestamp), you can use a case statement but it gets long.
I think this will do it:
This should do the trick, assuming that the columns
Month
andYear
are integers and Month has the domain 1-12:If
Month
is 0 you'll get '---' as the month; if it's less than 0 or greater than 12, you'll get some sort of blooey.You could create a function to convert the month value, like this...
Then you can...
If you want a 3 char month then change last last on function to...