How to convert 'weekday' from number into 'string'

D

Dave Neve

Hi

I'd like to know how to convert the following code so that it gives a day in
letters ie Monday, Tuesday etc rather than a number.

Thanks in advance

Sub fulldate()

MsgBox ("Nous sommes le " & Weekday((Date)) _
& " " & Str(Day(Date)) _
& " " & MonthName(Month(Date)) _
& " " & Str(Year(Date)))


End Sub
 
P

Peter Hewett

Hi Dave Neve

Just adding a little to what Perry has said, you can use the Format function to
do the whole thing in one go:

MsgBox Format$(Date, "dddd, dd mmmm yyyy")

HTH + Cheers - Peter
 
J

Jay Freedman

Hi Dave

In Word 2000 and later, the WeekdayName function will return the
correct name:

MsgBox ("Nous sommes le " & WeekdayName(Weekday(Date)) _

I don't have a system set up for multiple languages, but I believe
that WeekdayName returns the correct string for the language you
choose for Windows in the Regional and Language Options dialog.

For Word 97, the WeekdayName and MonthName functions don't exist, so
you would have to define a couple of arrays like this:

Dim WeekdayName As Variant
Dim MonthName As Variant
WeekdayName = Array("Sunday", "Monday", "Tuesday", _
"Wednesday", "Thursday", "Friday", "Saturday")
MonthName = Array("January", "February", "March", _
"April", "May", "June", "July", "August", _
"September", "October", "November", "December")

or the equivalent for the language you expect to use.
 

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