LKearney
asked on
American Dates
We have a vb.net app.
Is there a way that we can override the regional settings so that all dates are displayed as dd/mm/yyyy format throughout the application?
This is to overcome where the user has it set to American or mm/dd/yyyy which gives some functions in our application a problem.
Target Systems are Vista, Win XP , Server 2003 & Server 2008
Thanks
Is there a way that we can override the regional settings so that all dates are displayed as dd/mm/yyyy format throughout the application?
This is to overcome where the user has it set to American or mm/dd/yyyy which gives some functions in our application a problem.
Target Systems are Vista, Win XP , Server 2003 & Server 2008
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Abel,
will give that a try in a small vb.net app.
Take it, it changes the Date Format in Regional Settings for the user for good, or just on this running of the app??
Notice on Vista that the user can change the format of the date as well. i.e. to a d/m/yy format or something else. Will using the above code change it to an English Date in format dd/mm/yyyy, if the user has changed the format of date previously??
Thanks so much for your help, it is most appreciated.
Larry
will give that a try in a small vb.net app.
Take it, it changes the Date Format in Regional Settings for the user for good, or just on this running of the app??
Notice on Vista that the user can change the format of the date as well. i.e. to a d/m/yy format or something else. Will using the above code change it to an English Date in format dd/mm/yyyy, if the user has changed the format of date previously??
Thanks so much for your help, it is most appreciated.
Larry
> or just on this running of the app??
just on the app.
> Will using the above code change it to an English Date in format dd/mm/yyyy, if the user has changed the format of date previously??
it will not use a user-specified format. Which means: yes, it will use the english date format
just on the app.
> Will using the above code change it to an English Date in format dd/mm/yyyy, if the user has changed the format of date previously??
it will not use a user-specified format. Which means: yes, it will use the english date format
ASKER
We ran it in a small app and it works absolutely brilliantly for a system with regional settings US. Thank you so much.
Can I ask an additional question on this issue, if I may
We ran that code and ask for Msgbox(Today) and it returns in the date format for whatever was set for that region (UK) in the first place.
However, have one issue in Vista, where the date format for a specific region can be set to many formats(e.g. yyyy-mm-dd), so when we set it to en-GB as per your code, it leaves the format as was set for that region.
How can we set the Current Format to UK (your code does this perfectly above) but also set the date format for that current region to dd-mm-yyyy as our default.
We'd be most grateful for your guidance, as this would be our perfectist conclusion to this issue, and could sleep easy tonight, never to worry about what if the dates are wrong format!!
Thanks again abel
Can I ask an additional question on this issue, if I may
We ran that code and ask for Msgbox(Today) and it returns in the date format for whatever was set for that region (UK) in the first place.
However, have one issue in Vista, where the date format for a specific region can be set to many formats(e.g. yyyy-mm-dd), so when we set it to en-GB as per your code, it leaves the format as was set for that region.
How can we set the Current Format to UK (your code does this perfectly above) but also set the date format for that current region to dd-mm-yyyy as our default.
We'd be most grateful for your guidance, as this would be our perfectist conclusion to this issue, and could sleep easy tonight, never to worry about what if the dates are wrong format!!
Thanks again abel
That's an interesting question and since I'm on Vista myself, I can test it, too. But I don't know a solution, yet, apart from writing your own wrapper functions. You know, the problem with this is, that Microsoft tries to give the entire Windows system, and any applications running on it, the same look and feel for users. That means, you have to take that extra step to be disobedient to that rule...
I'll look into it, though.
I'll look into it, though.
ASKER
Abel thanks so much.
You'll be getting the points regardless. As we'll cover 95% of issues that might occur for our users with your solution. The extra issue has arisen beacause fo a "what if" question really. It's be brilliant is we could solve though!!
I was looking into it, and found something around on google around a search for
"Date Format Thread.CurrentThread.Curre ntUICultur e = Thread.CurrentThread.Curre ntCulture"
but got a little confused with it all.
Thanks so much for your help!
You'll be getting the points regardless. As we'll cover 95% of issues that might occur for our users with your solution. The extra issue has arisen beacause fo a "what if" question really. It's be brilliant is we could solve though!!
I was looking into it, and found something around on google around a search for
"Date Format Thread.CurrentThread.Curre
but got a little confused with it all.
Thanks so much for your help!
Actually, this appears to be very easy. Just set the DateSeparator in your newly created culture:
' overriding culture settings '
Dim culture As CultureInfo = System.Globalization.CultureInfo.CreateSpecificCulture("en-US")
culture.DateTimeFormat.DateSeparator = "/"
Thread.CurrentThread.CurrentCulture = culture
Thread.CurrentThread.CurrentUICulture = culture
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You are a god damn hero, and guru all rolled into one!!
in way of a viritual british pint, I've added another 50 points onto Points. Wish it was more, but running low at the moment.
Thanks so much.
To anyone searching in the future, this is the fix!!!
in way of a viritual british pint, I've added another 50 points onto Points. Wish it was more, but running low at the moment.
Thanks so much.
To anyone searching in the future, this is the fix!!!
ASKER
Excelklent Answer. Going away from post with more than my expectations in simplicity and speed of solution.
Thanks so much Abel.
Thanks so much Abel.
> Excelklent Answer. Going away from post with more than my > expectations in simplicity and speed of solution.> Thanks so much Abel.
Those are nice compliments (had to repeat them here because they are not visible to others then you and me). Thanks so much and hope to help you in the future.
Those are nice compliments (had to repeat them here because they are not visible to others then you and me). Thanks so much and hope to help you in the future.
Open in new window