• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 514
  • Last Modified:

Problem in converting German dates to DateTime format

Hello all,

I am getting a problem in my application.
I am importing data from a text file into a database table.
One of my field is of DateTime datatype.
Now, problem is dates are written in German language in that text file, for e.g.: 31-Mar-10 is written as 31-Mrz-10 and 1-May-10 is written as 1-Mai-10.
While importing, it is giving me error as "String is not a valid DateTime format".

Can anyone tell me how can i convert these german datatime strings to DateTime format.

Thanks,
Nagendra. .
0
RETAILREALM
Asked:
RETAILREALM
1 Solution
 
enkorCommented:
if you have access to admin the server, set up the IIS and DB localization and culture to German and check the preset default variable formats
0
 
wdosanjosCommented:
Use DateTime.Parse(string, CultureInfo), as indicated below:

var german = new System.Globalization.CultureInfo("de-DE");
String date = "31-Mrz-10";

DateTime dt = DateTime.Parse(date, german);
Console.WriteLine(dt);

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now