Solved

Convert DateTime error:

Posted on 2016-08-15
5
37 Views
Last Modified: 2016-08-15
Hi,

I'm getting an error when trying to convert a datetime to a datetime.  I don't know why.

Date Error
0
Comment
Question by:SmashAndGrab
  • 2
  • 2
5 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
can you try to set your value to 08/26/2016 ?
0
 
LVL 78

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
Comment Utility
Get rid of the ()'s or
DateTime myDate = DateTime.ParseExact("2009-05-08 14:40:52,531", "(DD-MM-YYYY HH:mm)",
                                       System.Globalization.CultureInfo.InvariantCulture)

IFormatProvider culture = new System.Globalization.CultureInfo("fr-FR", true);
// Alternate choice: If the string has been input by an end user, you might
// want to format it according to the current culture:
// IFormatProvider culture = System.Threading.Thread.CurrentThread.CurrentCulture;
DateTime dt2 = DateTime.Parse(date, culture, System.Globalization.DateTimeStyles.AssumeLocal)
0
 

Author Comment

by:SmashAndGrab
Comment Utility
just tried this..


error
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
since you sepcify MM, have you tried: 26/08/2016 ?
0
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
Comment Utility
you are going to have to do some work to get the string into something datetime can work with.. Months are 2 digits not 1 digit (they may also be 3 characters) I'd fix your input so that it returns 2 digits for the month or you have to do some string manipulation for months prior to October.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
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…

744 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

15 Experts available now in Live!

Get 1:1 Help Now