By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,650 Members | 1,823 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,650 IT Pros & Developers. It's quick & easy.

Help! Problem with DateTime, SQL and localization

P: n/a
Hi there,

I am desperate and need help on this from someone who actually knows what he
does... cuz I certainly don't ;-)

This is the situation:
I have an ASP.NET web application (written in VB.NET) in which the user can
create a job that will be run later by a service running in the background.
For tiing the job, the user can enter a date and a time. These values are
stored within an SQL table and the service polls this table periodically for
jobs to be executed.

Sounds simple.

But: In what way do I have to cope with the DateTime values, so that I don't
get into trouble when having different languages used on the server? I.e. the
code has to work on an english machine as well as on a german one.

Since SQL was really troublesome, I changed the tablestructure to store
DateTime values as varchar. The idea then was to convert every value to be
stored within this table into a specific type: 1/14/2005 15:43:00 for example
for January, 14th. Afterwards, when getting this value back into the service
or the webapplication, I wanted VB.NET to know this format and convert it
into the user defined culture.

This way, the display on the screen would be user dependent while storing
the values in a specific way on the other hand.

I used CurrentCulture for the user defined one and InvariantCulture for the
values to be stored in the database.

But whatever I try, I am still having mayor problems. Under specific
circumstances, I have DateTime.Parse reporting the value couldn't be
identified as a valid DateTime value...

However, ... having explained, what I want to achieve: Could anyone please
explain to me the way I should handle this?

Many many thanks in advance,
Christian.

Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Did you use DateTime.Parse Method (String, IFormatProvider)?
I think it's OK if you use InvariantCulture for IFormatProvider.
Nov 19 '05 #2

P: n/a
I convert all dates to yyyymmdd in SQL Server before inserting into the
table.

MattC
"Tronex" <Tr****@discussions.microsoft.com> wrote in message
news:00**********************************@microsof t.com...
Hi there,

I am desperate and need help on this from someone who actually knows what
he
does... cuz I certainly don't ;-)

This is the situation:
I have an ASP.NET web application (written in VB.NET) in which the user
can
create a job that will be run later by a service running in the
background.
For tiing the job, the user can enter a date and a time. These values are
stored within an SQL table and the service polls this table periodically
for
jobs to be executed.

Sounds simple.

But: In what way do I have to cope with the DateTime values, so that I
don't
get into trouble when having different languages used on the server? I.e.
the
code has to work on an english machine as well as on a german one.

Since SQL was really troublesome, I changed the tablestructure to store
DateTime values as varchar. The idea then was to convert every value to be
stored within this table into a specific type: 1/14/2005 15:43:00 for
example
for January, 14th. Afterwards, when getting this value back into the
service
or the webapplication, I wanted VB.NET to know this format and convert it
into the user defined culture.

This way, the display on the screen would be user dependent while storing
the values in a specific way on the other hand.

I used CurrentCulture for the user defined one and InvariantCulture for
the
values to be stored in the database.

But whatever I try, I am still having mayor problems. Under specific
circumstances, I have DateTime.Parse reporting the value couldn't be
identified as a valid DateTime value...

However, ... having explained, what I want to achieve: Could anyone please
explain to me the way I should handle this?

Many many thanks in advance,
Christian.

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.