0

That's my problem: I read the date from a xml file in the yyyy-mm-ddThh:mm:ss format. Example: <Date_Creation>2015-06-10T08:56:44</Date_Creation>

Then I want to write this date in a new file but only in this format: 06/10/2015 (that is MM/dd/yyy, without the time).

What I tried at first it was:

Date_Creation = Date.Parse(noeudEnf.InnerText.ToString)

But then I get the time and I don't want it. So I tried to do this:

Date_Creation = DateTime.ParseExact(Date_Creation, "dd/MM/yyyy", CultureInfo.InvariantCulture)

I thought the problem was the "-" instead of "/" in the xml file. I replaced them but I got the same. I don't know what's next!

1 Answer 1

1

First, you need to parse the original to be an instance of the DateTime struct. It just holds the date and time data, not any format:

Date_Creation = Date.Parse(noeudEnf.InnerText.ToString)

Then you can format it as a string:

SomeString = Date_Creation.ToString("dd/MM/yyyy")
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! That was useful, it succesed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.