Thursday, March 22, 2012

Simple Date Problem

Hi

I have a one-line web app which works on my test server but not on the
remote server. The line of code is:

Dim myDate As Date = "31/12/2005"

This works here (New Zealand), but when I upload it to the server (USA), I
get the following error:

Cast from string "31/12/2005" to type 'Date' is not valid.

I can see why the problem's occurring - Americans write their dates
backwards. How can I fix this? There must be a setting, similar to SQL
Server's "Language=British", that will make it recognise the dates
correctly. However, I don't know where this setting is :)

Thanks in advance
ChrisHi Chris,

Add this to your web.config and asjust it to your culture :

<configuration>
<system.web>
<globalization
culture="en-US"
uiCulture="de-DE"
/>
</system.web>
</configuration
Let me know if you have any more questions..

Cheers,
Tom Pester

> Hi
> I have a one-line web app which works on my test server but not on the
> remote server. The line of code is:
> Dim myDate As Date = "31/12/2005"
> This works here (New Zealand), but when I upload it to the server
> (USA), I get the following error:
> Cast from string "31/12/2005" to type 'Date' is not valid.
> I can see why the problem's occurring - Americans write their dates
> backwards. How can I fix this? There must be a setting, similar to SQL
> Server's "Language=British", that will make it recognise the dates
> correctly. However, I don't know where this setting is :)
> Thanks in advance
> Chris
I knew it'd be something simple :)

Thanks!

On 23/6/05 2:50 PM, in article
a1a977a236e1e8c745c62dec749a@.news.microsoft.com,
"Tom.PesterDELETETHISSS@.pandora.be" <Tom.PesterDELETETHISSS@.pandora.be>
wrote:

> Hi Chris,
> Add this to your web.config and asjust it to your culture :
> <configuration>
> <system.web>
> <globalization
> culture="en-US"
> uiCulture="de-DE"
> />
> </system.web>
> </configuration>
> Let me know if you have any more questions..
> Cheers,
> Tom Pester
>> Hi
>>
>> I have a one-line web app which works on my test server but not on the
>> remote server. The line of code is:
>>
>> Dim myDate As Date = "31/12/2005"
>>
>> This works here (New Zealand), but when I upload it to the server
>> (USA), I get the following error:
>>
>> Cast from string "31/12/2005" to type 'Date' is not valid.
>>
>> I can see why the problem's occurring - Americans write their dates
>> backwards. How can I fix this? There must be a setting, similar to SQL
>> Server's "Language=British", that will make it recognise the dates
>> correctly. However, I don't know where this setting is :)
>>
>> Thanks in advance
>> Chris

0 comments:

Post a Comment