Results 1 to 4 of 4

Thread: Regional Settings

  1. #1
    rickster57 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 1.1 (VS 2003)
    Join Date
    Sep 2007
    Posts
    2
    Reputation
    0

    Regional Settings

    Does any one know how to change the Date Format in Regional Settings via vb.net?
    I'm trying to change it to yyyy-MM-dd using the following code that I found on the internet but it changes nothing.
    Thanks in advance

    Dim ci As New System.Globalization.CultureInfo("en-US", True)
    System.Threading.Thread.CurrentThread.CurrentUICul ture = New System.Globalization.CultureInfo("en-US")

    Dim newCi As System.Globalization.CultureInfo = CType(ci.Clone(), System.Globalization.CultureInfo)

    newCi.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd"
    System.Threading.Thread.CurrentThread.CurrentCultu re = newCi

  2. #2
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,204
    Reputation
    2369
    You should not change someones OS regional settings, instead accomodate your application to handle/output data formatting when running in different cultures.

  3. #3
    rickster57 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 1.1 (VS 2003)
    Join Date
    Sep 2007
    Posts
    2
    Reputation
    0
    Thanks John for the quick reply and advice. I am new to vb.net and have found that if I don't set the regional setting to yyyy-MM-dd not all records are returned in my sql statement searching for records in a date range..

    Never had the issue in Microsoft Access.

    Something I'm missing?

    Thanks for the help and advice.

  4. #4
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,204
    Reputation
    2369
    I'm sure you can specify query parameters as Date (which is culture independent) or format a date string the string column that should represent a date string would comply to. Ask in data access forums. Changing the computers culture is not the way to go.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking