Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Way to covert a Decimal "month" value to "String"?

Status
Not open for further replies.

Keetso

Technical User
Nov 18, 2003
49
CA
Hi.

I was wondering if there's a way to take the decimal value of a month and covert it to the string value.

For example 1 = January, 2 = February, etc
 
Have you tried the MonthName function? For instance, in a textcontrol:

[tt]=monthname([txtcontrolname])[/tt]

- replace txtcontrolname with the name of your control holding 1-12...

Roy-Vidar
 
I'm not sure how many version MonthName() has been around. Another alternative is
=DateSerial(Year(Date()),[MonthNumber],1)
You can format this anyway you want.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
If I use the "MonthName" function in an access 2000 database in a Win 2000 environment it works perfectly, but for those users with Access 2000 in a WinXP environment it fails.

Any ideas why?

TIA

Bob
 
Hi Duane.

Thanks for the info.

I checked the references on both computers and they are identical. I unchecked the references I could on the broken pc (the one running WinXP), closed VBasic, and then rechecked them again with no success. The "MonthName" function still won't run.

Is there anything else I can check? If not, would it be possible to explain the "DateSerial" function and how to use it to return the string month value from the numerical month value?

Again, many thanks for all your help.

Bob
 
This returns a date that is the first day of the month numbered MonthNumber.
=DateSerial(Year(Date()),[MonthNumber],1)
You could set the format of the text box to:
Format: mmmm
Or, you could use:
=Format(DateSerial(Year(Date()),[MonthNumber],1),"mmmm")

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Thanks Duane.

Used
=Format(DateSerial(Year(Date(),[MonthNumber],1),"mmmm")

Worked perfectly.

Thanks again!

Bob
 
Another related question if I may.

Using the DateSerial Function above, is there a way to modify it to return the total number of days in the "month" returned?

For example, if the user types the value 10 (numeric) in the parameter [MonthNumber], the function

=Format(DateSerial(Year(Date(),[MonthNumber],1),"mmmm")

returns the string value of "October".

What I'm wondering is if you could modify this DateSerial function to take the same [MonthNumber] value (in this example, 10 (for October) and return the value "31" (the number of days in the month of October?

TIA

K

 
=Day(DateSerial(Year(Date()),[MonthNumber]+1,0))

Duane
MS Access MVP
[green]Ask a great question, get a great answer.[/green]
[red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
[blue]Ask me about my grandson, get a grand answer.[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top