Getting the month name from a date

  • Thread starter Thread starter David Gartrell
  • Start date Start date
D

David Gartrell

Hi there,

Could anyone help me with a little problem i'm having in SQL.

What I'd like to be able to do is to extract the name of the month from any
date so that I can group figures in a report by the name of the month. I've
tried using both the MONTH and DATEPART functions but all i've succeeding in
doing so far is getting the month number e.g. '6' rather than the month name
'JUNE'. I thought that if I specified "mmmm" in the date part function
instead of "m" then it would return the name of the month, but instead all
it gave me was an error.

If anyone can tell me a way of doing this then i'd be very grateful

Many thanks

David.
 
This should work in any version of Access:
Format([MyDate], "mmmm")

More recent versions support MonthName(), so if you want a more
circumlocutory approach that fails in older versions:
MonthName(Month([MyDate]))
 
Allen you're a star! Thank you very much!


Allen Browne said:
This should work in any version of Access:
Format([MyDate], "mmmm")

More recent versions support MonthName(), so if you want a more
circumlocutory approach that fails in older versions:
MonthName(Month([MyDate]))

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

David Gartrell said:
Hi there,

Could anyone help me with a little problem i'm having in SQL.

What I'd like to be able to do is to extract the name of the month from
any date so that I can group figures in a report by the name of the
month. I've tried using both the MONTH and DATEPART functions but all
i've succeeding in doing so far is getting the month number e.g. '6'
rather than the month name 'JUNE'. I thought that if I specified "mmmm"
in the date part function instead of "m" then it would return the name of
the month, but instead all it gave me was an error.

If anyone can tell me a way of doing this then i'd be very grateful

Many thanks

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top