Louis01
asked on
VB Format (Date) function gives German Date with English Regional Options
Hi
I have come accross an interesting feature / bug in VB and could not find any information regarding a solution...
Maybe someone has more knowledge regarding it...
Create (In VB6) a Dll (MyDll) with a class (MyClass) with a method (showDate)
The method should look like this:
Public Function showDate() as string
showDate = Format(now, "dd mmmm yyyy")
End Function
Compile it and call it in an ASP page
...
Dim oX
set oX = Server.createObject("MyDll .MyClass")
Response.write oX.showDate
...
The machine was originally installed with German Regional Options and other German software...
After that the Regional Settings was changed to English (W2k Server)
The problem is that I expect to see an output of
11 February 2003 (on 11 Feb 2004)
However, on this server I see
11 Februar 2003 - GERMAN DATE
_
Anyone ever come accross the same thing?
p.s. FormatDateTime(now, vbLongDate) in ASP works fine
Thanks
Louis
I have come accross an interesting feature / bug in VB and could not find any information regarding a solution...
Maybe someone has more knowledge regarding it...
Create (In VB6) a Dll (MyDll) with a class (MyClass) with a method (showDate)
The method should look like this:
Public Function showDate() as string
showDate = Format(now, "dd mmmm yyyy")
End Function
Compile it and call it in an ASP page
...
Dim oX
set oX = Server.createObject("MyDll
Response.write oX.showDate
...
The machine was originally installed with German Regional Options and other German software...
After that the Regional Settings was changed to English (W2k Server)
The problem is that I expect to see an output of
11 February 2003 (on 11 Feb 2004)
However, on this server I see
11 Februar 2003 - GERMAN DATE
_
Anyone ever come accross the same thing?
p.s. FormatDateTime(now, vbLongDate) in ASP works fine
Thanks
Louis
Why dont you just do replace
'April,August,September,No vember are the same in german so no need to include them.
showDate = Replace(Format(now, "dd mmmm yyyy"),"January","Januar")
showDate = Replace(Format(now, "dd mmmm yyyy"),"February","Februar ")
showDate = Replace(Format(now, "dd mmmm yyyy"),"March","März")
showDate = Replace(Format(now, "dd mmmm yyyy"),"May","Mai")
showDate = Replace(Format(now, "dd mmmm yyyy"),"June","Juni")
showDate = Replace(Format(now, "dd mmmm yyyy"),"July","Juli")
showDate = Replace(Format(now, "dd mmmm yyyy"),"October","Oktober" )
showDate = Replace(Format(now, "dd mmmm yyyy"),"December","Dezembe r")
msgbox ShowDate
Good Luck
-Brian
'April,August,September,No
showDate = Replace(Format(now, "dd mmmm yyyy"),"January","Januar")
showDate = Replace(Format(now, "dd mmmm yyyy"),"February","Februar
showDate = Replace(Format(now, "dd mmmm yyyy"),"March","März")
showDate = Replace(Format(now, "dd mmmm yyyy"),"May","Mai")
showDate = Replace(Format(now, "dd mmmm yyyy"),"June","Juni")
showDate = Replace(Format(now, "dd mmmm yyyy"),"July","Juli")
showDate = Replace(Format(now, "dd mmmm yyyy"),"October","Oktober"
showDate = Replace(Format(now, "dd mmmm yyyy"),"December","Dezembe
msgbox ShowDate
Good Luck
-Brian
ASKER
Thanks - but I need to solve the problem.
A lot in the system depends on the Format function with a long date type mask returning the month in the language in the Regional options.
The replace method suggested by Brian would work well, but then you would have to apply it for 50 other languages as well, unless this problem is only in switching between german and english locales - but I doubt it.
The system needs to be generic and could work against any language, so catering for incorrect dates is going to be a massive overhead.
A lot in the system depends on the Format function with a long date type mask returning the month in the language in the Regional options.
The replace method suggested by Brian would work well, but then you would have to apply it for 50 other languages as well, unless this problem is only in switching between german and english locales - but I doubt it.
The system needs to be generic and could work against any language, so catering for incorrect dates is going to be a massive overhead.
>After that the Regional Settings was changed to English (W2k Server)
You need to change the "Gebietsschema" to English, for EACH USER.
Also, check the Date format on the "Date" tab.
The Default/Standard can remain in German (requires a reboot and changes the ascii table, fonts, etc. used).
Your program should be using hard coded dates in US format, or using date variable or date conversion functions. Store dates in the DB always in Date fields, passed in US format, as opposed to using Text fields.
So, no matter the setting for the language, or the settings for the Date/Number formats, CDate(TheDate) and CDbl(TheNumber) will always return the value formated according to those settings:
TextBox1 Input by the user in the date format as set in the system settings.
Dim myDate as Date
'Validate and Assign the input to a date variable
If IsDate(Text1.Text) Then
myDate = CDate(Text1.Text)
myDate = myDate + 10
MsgBox "The Date in Local Format: " & CStr(myDate)
MsgBox "The Date in Local Format: " & Format$(myDate, "dd MMM yyyy")
MsgBox "The Date in Local Format: " & Format$(myDate, "Long Date")
MsgBox "The Date in US Short Format: " & Format$(myDate, "MM\/dd\/yyyy")
'Store the Date in the Database:
'SQL SERVER
'rsADO.Execute "UPDATE SomeTable SET SomeDateField = '" & Format$(myDate, "MM\/dd\/yyyy") & "'"
'JET MDB
'rsADO.Execute "UPDATE SomeTable SET SomeDateField = #" & Format$(myDate, "MM\/dd\/yyyy") & "#"
'Best is to always use ISO 92 format. Then you are sure to always have the right format:
'JET MDB
rsADO.Execute "UPDATE SomeTable SET SomeDateField = #" & Format$(myDate, "yyyy-MM-dd") & "#"
Else
'Error out
End If
If you adhear to this, then the user can have their system set to any laguage and your program will always display the correct format/wording.
>>FormatDateTime(now, vbLongDate) in ASP works fine
Why don't you use this in your dll?
Why don't you use this in your dll?
ASKER
I was able to solve the problem myself.
When the system is installed, the following key is created based on the Administrator settings. After this however there is no way to change it except through the registry.
[HKEY_USERS\.Default\Contr ol Panel\International]
"Locale"="00001C09"
Changing this did the trick...
Thank you for your input anyhow....
Anyone know how I go about getting this question resolved though?
When the system is installed, the following key is created based on the Administrator settings. After this however there is no way to change it except through the registry.
[HKEY_USERS\.Default\Contr
"Locale"="00001C09"
Changing this did the trick...
Thank you for your input anyhow....
Anyone know how I go about getting this question resolved though?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
download this code : http://www.cyberactivex.com/download/InternationalLocales.zip
It will help you a lot to anderstand, and features to your ASP and VB apps