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

How to retrieve day name by date for multi-language?

Status
Not open for further replies.

tg2003

IS-IT--Management
Feb 6, 2003
270
IL
Hello,

I have to retrieve the day name by the absolute date. e.g. Today is 11/17/2008, so I need that this function(?) will retrieve "Monday".

Currently I'm using
Code:
Dim day As String = DateTime.Today.ToString("ddd")
which makes the work only if I use "English" as may regional language (it returns Sun/Mon/Tue etc.). This code doesn't work on other languages, in hence I'm looking for another function that can calculate the day by the date, and always returns its name in English. I'm planning my app to be multi-language.

If you know about such function - please let me know.
Many thanks!
 
Not sure of a built-in function, but you could do this simply enough with your own function. Add a new module to your project and try something like this:
Code:
Public Function MyWeekDayName(MyDate As Date) As String

    Dim TheName As String = String.Empty

    Select Case MyDate.DayOfWeek
        Case 1
            TheName = "Mon"
        Case 2
            TheName = "Tue"
        ' And So On
    End Select

    Return TheName

End Function

Then anywhere you want to display this name, you need to call it like:

Me.TextBox1.Text = MyWeekDayName(DateTime.Today)

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB.NET Programmer
 
Thanks! I will try this approach.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top