Solved

Problem in converting German dates to DateTime format

Posted on 2011-03-23
2
479 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
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 500 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

746 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now