MONTH

  • Thread starter Thread starter Dimitris Nikolakakis
  • Start date Start date
D

Dimitris Nikolakakis

I have a field (number integer) and I want according to this value to
display the name of the month in a query or a form or a report.

e.g.
value = 4 then month = APRIL

I know that I can do it with an extra table (value, nameOFmonth as fields)
but I was wondering if there was any function for this.

thanks
 
SELECT MonthName([MonthNumber]) AS NameOfMonth FROM YourTable

This assumes that your month numbers are 1=January, 2=February, etc. If your
numbers were 0-based, for example, 0=January, 1 = February, you'd need to
adjust them in the calculation ...

MonthName([MonthNumber] + 1) etc.


--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
And if you're using a version of Access that doesn't include the MonthName
function (I don't believe it was introduced until Access 2000), you could
use the DateSerial function to create an actual date, and then the format
function to convert that date to a month:

Format(DateSerial(2004, MonthNumber, 1), "mmmm")


--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Brendan Reynolds said:
SELECT MonthName([MonthNumber]) AS NameOfMonth FROM YourTable

This assumes that your month numbers are 1=January, 2=February, etc. If your
numbers were 0-based, for example, 0=January, 1 = February, you'd need to
adjust them in the calculation ...

MonthName([MonthNumber] + 1) etc.


--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com


Dimitris Nikolakakis said:
I have a field (number integer) and I want according to this value to
display the name of the month in a query or a form or a report.

e.g.
value = 4 then month = APRIL

I know that I can do it with an extra table (value, nameOFmonth as fields)
but I was wondering if there was any function for this.

thanks
 
Back
Top