Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6023595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:01:43+00:00 2026-05-23T04:01:43+00:00

I have a string 13/6/2011.I have to convert it into DateTime. For this i

  • 0

I have a string “13/6/2011”.I have to convert it into DateTime. For this i am using

 DateTime.ParseExact("13/6/2011","DD/MM/YYYY",null);

But it showing

 String was not recognized as a valid DateTime

exception.
Any idea why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:01:44+00:00Added an answer on May 23, 2026 at 4:01 am

    In addition to the “6” vs “06” problem that ChrisF has mentioned, your format string is incorrect. Day-of-month is “dd” and year is “yyyy”, so you should have a format of “dd/MM/yyyy”.

    Additionally, I’d recommend explicitly passing in CultureInfo.InvariantCulture, as otherwise the “/” could actually be treated as a different (culture-specific) date separator. (Another alternative is to quote the slashes, but I think using an invariant culture pins things down more.)

    In other words, I’d use something like this:

    // Sample for text: 13/06/2011
    DateTime date = DateTime.ParseExact(text, "dd/MM/yyyy",
                                        CultureInfo.InvariantCulture);
    

    If you don’t necessarily have a two-digit day or month, use:

    DateTime date = DateTime.ParseExact(text, "d/M/yyyy",
                                        CultureInfo.InvariantCulture);
    

    It’s not immediately clear to me whether that also copes with (say) 13/06/2011 though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a date string in DD-MM-YYYY (28-11-2011) I want to convert it into
I have a string THURSDAY 26th JANUARY 2011. When I format this using CultureInfo.ToTitleCase():
I have a time string which looks like this 2011-06-11T08:51:51Z I'm not sure what
I have the following date: 2011-05-24T11:40:41Z How can I convert this into a Joda
Folks, I have a string date which I can convert to numeric using: =DateValue(1/2/2011)
I have a String as strikedate=2011-11-19T00:00:00.000-05:00 I need to put this into a java.util.Date
I have been passed a date string that looks like this: Thu%20Mar%2011%202010%2015%3A09%3A11%20GMT%2B0000%20(BST) I want
I have string like \LESSING\root\cimv2:Win32_UserAccount.Domain=LESSING,Name=Admin How to convert it to LESSING\Admin using Framework?
I have to convert a long string of data into values so that I
I have a datetime string being provided to me in the following format: yyyy-MM-dd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.