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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String.Format - WeekdayName Replacement

Status
Not open for further replies.
Joined
Jan 9, 2003
Messages
147
Location
US
Hi,

Since this code:
Code:
WeekdayName(DayOfWeek.Monday, True)

returns "Sun" (i.e. Sunday). I'd like to find a way to get String.Format (or some other method from the Date namespace) to do the same thing (return the abbriviated day of the week). My guess is that the error in the above code is some sort of combination of old Visual Basic function, that FirstDayofWeek thing, and whatever.

I've gotten around it by using:
Code:
Left(MyDateVariable.DayOfWeek.ToString, 3)

which is working pretty well, but there must be a .NET way to do it.

Thanks,
-FD
 
Yes there is a way:
Code:
Response.Write(System.Globalization.DateTimeFormatInfo.CurrentInfo.AbbreviatedDayNames(System.DateTime.Now.DayOfWeek))


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Ah ha, I knew it. Takes a bit of work to get there though huh? lol.

Thanks ca8msm.


-FD
 
Yeah, you might want to add an import for "System.Globalization.DateTimeFormatInfo" otherwise it becomes a bit of a mouthful!


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Man, there's all kinds of neat stuff down in there. Such as:
Code:
      Dim Culture As System.Globalization.CultureInfo
      For Each Culture In System.Globalization.CultureInfo.GetCultures(Globalization.CultureTypes.AllCultures)
         Response.Write(Culture.EnglishName & "<br>")
      Next

or even better
Code:
      Dim Culture As System.Globalization.CultureInfo
      For Each Culture In System.Globalization.CultureInfo.GetCultures(Globalization.CultureTypes.AllCultures)
         Response.Write(Culture.NativeName & "<br>")
      Next

:-)

-FD
 
Looks like we have another convert to writing world-ready applications!

Chip H.


____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top