Getting the month name from a 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.
 
A

Allen Browne

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]))
 
D

David Gartrell

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
 
Top