Formatting the month of a date

A

Alejandro

Hello there,

I'm extracting the month of a date in a query using Month(date). Since the
criteria is for the query to show the records where the month matches the
month selected in a combo box (which has the months in letters), I need to
add some formating function to Month(date) so that the month in reference
shows in letters (like "November") instead of the number ("11").

Thanks!
 
F

fredg

Hello there,

I'm extracting the month of a date in a query using Month(date). Since the
criteria is for the query to show the records where the month matches the
month selected in a combo box (which has the months in letters), I need to
add some formating function to Month(date) so that the month in reference
shows in letters (like "November") instead of the number ("11").

Thanks!

Month(date) will return the month number, not the month name.

Add a new column to the query:
TheMonth:Format([DateField],"mmmm")

As criteria on this column you need to refer back to the combo box on
the form, using:
Forms!FormName!cboMonth

The month name must be in full text in the combo box, i.e. November
not Nov.

Also, I hope tha actual name of the date field is NOT Date.
Date is a reserved Access/VBA/Jet word and should not be used as a
field name.
For additional reserved words, see the Microsoft KnowledgeBase article
for your version of Access:

109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'

For an even more complete list of reserved words, see:
http://www.allenbrowne.com/AppIssueBadWord.html
 
A

Alejandro

It worked. Thanks!

fredg said:
Hello there,

I'm extracting the month of a date in a query using Month(date). Since the
criteria is for the query to show the records where the month matches the
month selected in a combo box (which has the months in letters), I need to
add some formating function to Month(date) so that the month in reference
shows in letters (like "November") instead of the number ("11").

Thanks!

Month(date) will return the month number, not the month name.

Add a new column to the query:
TheMonth:Format([DateField],"mmmm")

As criteria on this column you need to refer back to the combo box on
the form, using:
Forms!FormName!cboMonth

The month name must be in full text in the combo box, i.e. November
not Nov.

Also, I hope tha actual name of the date field is NOT Date.
Date is a reserved Access/VBA/Jet word and should not be used as a
field name.
For additional reserved words, see the Microsoft KnowledgeBase article
for your version of Access:

109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'

For an even more complete list of reserved words, see:
http://www.allenbrowne.com/AppIssueBadWord.html
 

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

Similar Threads


Top