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

  • Home
  • SEARCH
  • 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 7905463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:29:23+00:00 2026-06-03T10:29:23+00:00

I have tried all combinations of DateTime.Parse and ParseExact and they don’t work. I

  • 0

I have tried all combinations of DateTime.Parse and ParseExact and they don’t work. I keep getting the message “{“String was not recognized as a valid DateTime.”}” for both those functions. I have also tried Convert.ToDateTime and that don’t work. Just to check if I wasn’t dreaming, I wrote the following code:

Dim ExpiryDate As Date = System.DateTime.Now
Dim provider As New CultureInfo("en-US")
Try
     Dim strDate As String = Convert.ToString(ExpiryDate)
     ExpiryDate = DateTime.ParseExact(strDate, "mmddyy", provider)
Catch ex as exception
    'ex here says "{"String was not recognized as a valid DateTime."}"
End Try

I just want to take string in this form mm-dd-yyyy or mm/dd/yyyy and convert it to a date so I can test (greater than) against another date. Any help appreciated.

  • 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-06-03T10:29:30+00:00Added an answer on June 3, 2026 at 10:29 am

    First of all, the format string needs to match the string being parsed. Secondly, an “m” in the format string stands for minutes, not month. If your date is formatted as mm-dd-yyyy, try DateTime.ParseExact("04-08-2011", "MM-dd-yyyy", provider).

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

Sidebar

Related Questions

I have tried all the combinations of finds I can think of, and haven't
I have tried all the combinations in my little OOP brain of trying to
I have tried all the combinations I can think off but this form: class
I have tried all combinations of single quotes, double quotes etc but the following
I have tried all the solutions that have been provided including using PRAGMA but
I have tried almost all the solutions from SO but no success :(. I
i have tried looking online but had no luck, How i could delete all
How can I replace all line-endings in big file (>100MB)? I have tried to
All right so I tried using the button set. So fair, I have been
I want to write an insert query in Grails. I have tried all possible

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.