Convert number to month name

Can i convert just a number to the relevant month name?

eg 1=Jan, 5=May etc

cheers

monkey

This should do the trick, other date/time type stuff can be found here.

mysql> SELECT MONTHNAME('2008-02-03');
        -> 'February'

I ONLY have a number ie 1, 2 or 3

Create a dummy date…but include your actual month number, that will do the trick. I’m not certain if there is a MySql function that only accepts a single argument (month integer) and returns the month name.

Another way around it is by using your programming language, which ever one it is. I’m half assuming your using PHP and I’m not PHP proficient but I’m guessing there would be a suitable function for this purpose. If not create one, all that’s required is creating an array of month names and presto, job done.

SELECT MONTHNAME('2008-12-01' + INTERVAL [COLOR="Red"]n[/COLOR] MONTH) 

where n is your number

note that MONTHNAME is a mysql function, you can use something similar in other database systems (you did not mention which one you’re using)

:slight_smile: