[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Problem in converting German dates to DateTime format

Posted on 2011-03-23
2
Medium Priority
?
508 Views
Last Modified: 2012-08-14
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
Comment
Question by:RETAILREALM
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Expert Comment

by:enkor
ID: 35198011
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
 
LVL 23

Accepted Solution

by:
wdosanjos earned 2000 total points
ID: 35199510
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question