Date format

M

marwan hefnawy

In the VBA I tried the following:

MyDate = DateSerial(2004, 7, 30)
MsgBox Format(MyDate, "mmmm yyyy")

it gave me the month and the year in my language (as in the regional options
in windows control panel)
I want to force the result to give me "July 2004" regardless the settings in
the windows.
In a worksheet, I can format such a date with "B1mmm yyyy" to give me what I
want.
But in VBA, the "format" function didn't accept the "B1mmm yyyy" to format
MyDate.
Any ideas?
Thanks in advance
 
C

Charles

marwan hefnawy

Try something like this.


Sub my_date()
Dim MyDate
Dim mydat
MyDate = DateSerial(2004, 7, 30)
mydat = Format(MyDate, "mmmm-yyyy")

MsgBox mydat

End Sub

HTH

Charles
 
M

marwan hefnawy

Thank you Charles for your reply.
Unfortunatly my problem is not in the date separator between the month
and the year (a space or a dash).
My problem is that the month name and the year number is not written in
english words and I want them to be written in engilsh words (July 2004)
or (July-2004) doesn't matter to me.
Thanks anyway


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 

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

Top