This is one of the initial difficulties I found dealing with date and time for websites with cultures set to anything but the default. No problem with US formatted dates. However, with British formatted dates for example, you have to spend a lot of time formatting your strings within ASP.Net and your SQL server stored procedures. However, there is a way to do this as if you are programming with the default date and time format. Here’s how…
1. Connect to your server and expand Security node.
2. Expand Logins node and locate your user.
3. Right-click the user and click properties.
4. Find default language and set to your language. For example, I work mostly with British format dates (dd/mm/yyyy) so I set it to “British English”.
5. In your website’s web.config, add the following entry under the <system.web> node.
<globalization culture="en-GB"/>
For other supported cultures go to http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx
Now, sql server will always expect your dates to be “en-GB” formatted or whatever culture you have set it to be. No need to explicitly convert your date strings in ASP.Net or SQL Server.
0 comments:
Post a Comment