How to change the culture in a thread or application or program.

my VB.net 2005 Application is

My.Application.ChangeCulture("en-GB")

the problem is, my OS dateformat may be will not be matching my application culture.

e.g. 7 april 2007 at my application = 2 July at my OS

my prblem is: when I send 07-02-2007 to my database it will save depends on my OS format then when I retrieve the value it will be 02-07-2007, it changed from april to july




Answer this question

How to change the culture in a thread or application or program.

  • spolsky

    How about changing the system format Is the possible

    Changing the default country/region changes the standard settings for numbers, currencies, time, and date to those most commonly used for that country/region.

    Microsoft Windows XP

    1. In the Control Panel, click Date, Time, Language, and Regional Options.
    2. Click Regional and Language Options, and then click the Regional Options tab.
    3. Select the country/region you want to use from the list under Standards and formats.
    4. Click OK, and then restart your program.

    Microsoft Windows 2000

    1. In the Control Panel, double-click Regional Options.
    2. Use the Your locale (location) list to select the country/region you want to use as the default.
    3. If you don't see the item you want, first select the check box next to the appropriate language in the Language settings for the system box.
    4. Click OK, and then restart your program.

    Note When you change the country/region, settings, such as the format for displaying currency and date, may also change. Check all the tabs in the Regional and Language Options or Regional Options dialog box to make sure they are correct.



  • Alex Poon

    I'm really not sure what the problem is: a date is a date regardless of the culture. I don't use Access, but it should be irellevant.

    Simply inserting/modifying date/times as universal format inserts the data correctly. It doesn't matter what the application culture is, the OS culture or the Database culture.

    Insert the date as a universal date, becaue a universal date is culture insensitive: all databases should interpret it correctly.

    For example, simple Insert like this (Jan 12th, 2007):

    INSERT INTO PRODUCTION (starttime) VALUES ('2007-01-12 12:06:00')

    Works fine regardless of the UI culture. Likewise changing the UI culture from en-GB, fr-FR, de-DE or en-US while reading it back results in the correct date (Jan 12th). The database stores the date as a DateTime - which is universal. How it's formatted is up to you.



  • Paul Devine

    it is the same..

    maybe I didn't use it very well, may you write the insert statment



  • evci

    What database are you using Are you sure you can not modify the culture that the database is using I think this can be done on MS SQL server.

  • swatiabhyankar

    Another option is to explore the System.Globalization namespace:

    http://msdn2.microsoft.com/en-us/library/system.globalization(VS.80).aspx

    Specifically the DateTimeFormatInfo Class looks like it might be what you are looking for:

    http://msdn2.microsoft.com/en-us/library/system.globalization.datetimeformatinfo(VS.80).aspx

    You would just have to manipulate it any way you want when you retrieve it from the DB and again before updating the DB. I wish I had more time to try some code out for you, but hope this helps somehow.



  • Captain Baz

    Have you tried these methods to see if they have any effect:

    Dim d As DateTime

    d.ToLocalTime()

    d.ToUniversalTime()



  • Pawnder

    Sorry Dear,

    My column datatype is datetime,

    the problem is my Access database datetime format is same of OS, but My application is fixed format My.Application.ChangeCulture("en-GB")

    I hope to try to change your OS datetime format from ControlPanel and make your application fixed culture as me, and try to ceck the case



  • allison_h

    Thanks Mr. SJWhiteley

    Very nice words and it is soo logically but let me say some thing:

    01-02-2007 is the first of Feb. but also it is 2nd of Jan for other culture,

    now, how the database will differ between them, while there is no talks between DB and Application

    Now, depends on your logic the circle must be like following:

    Form Application dateformat -> convert to global format as (julian) --> insert into DB --> convert into DB Date Format.

    is this right



  • Alexander Marinov

    How do you "send" the date to the database Are you passing it as a string If so, you need to make sure that you use the same culture as the database.

    Best regards,
    Johan Stenberg



  • markusb9

    that is not possible, change all the customer system dateformat!!!

    sometimes their system related to another applications and any change will give up a problem



  • RichardSa

    Re-asking the question, What is the format of the column in the database that contains the date/time If it's a datetime data type, then it shouldn't matter. If it's astring, then you will have to get around poor design.

    You could insert you date/time as a universal Date/Time string - yyyy-MM-dd hh:mm:ss

    All cultures should interpret that correctly as a valid (ISO/DIN) date/time. It's the only format that won't cause confusion among cultures.



  • djklocek

    Sorry, I don't know much access... but can't you specify the date/time format for the column in access If so, you could do so. Also, don't you want to specify the date as #<date># instead

    Best regards,
    Johan Stenberg



  • solnt

    thanks, it is ok but the problem is how can I know what is the dateformat of the system OS not my application!!

  • JGttttt

    I'm using MS ACCESS2003.

    I'm using Insert statment insert into tbl1 (testdate) values ('"& date.now &"')

    so, how can I know what is the culture of the database



  • How to change the culture in a thread or application or program.