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!

String.Format - WeekdayName Replacement

Status
Not open for further replies.
Jan 9, 2003
147
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top