Solved

Convert DateTime error:

Posted on 2016-08-15
5
49 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 70

Expert Comment

by:Éric Moreau
ID: 41756248
can you try to set your value to 08/26/2016 ?
0
 
LVL 79

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
ID: 41756255
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
ID: 41756277
just tried this..


error
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 41756310
since you sepcify MM, have you tried: 26/08/2016 ?
0
 
LVL 79

Expert Comment

by:David Johnson, CD, MVP
ID: 41757199
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

776 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