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 465127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:20:42+00:00 2026-05-12T23:20:42+00:00

I have datetime strings that look can like any the following: 1 13 2009

  • 0

I have datetime strings that look can like any the following:

“1 13 2009 2300”, “1 14 2009 0”, “1 14 2009 100”

that I need to parse into a DateTime.

I have tried:

string[] sExpectedFormats = {"M d yyyy Hmm", "M d yyyy hmm", "M d yyyy 0"};
DateTime dtReportDateTime = DateTime.ParseExact(sReportDateTime, 
 sExpectedFormats, 
 System.Globalization.CultureInfo.InvariantCulture,
 System.Globalization.DateTimeStyles.None);

but it fails on the third one “1 14 2009 100”. I am not sure what format to use for that?

To clarify, I get this data in a feed as a date part “1 14” and a time part “100”, so am concatenating it so I can parse into a DateTime.

Thanks

  • 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-12T23:20:42+00:00Added an answer on May 12, 2026 at 11:20 pm

    I suspect that it’s interpreting the “100” as “10” followed by “0” – i.e. parse the H or h as “10” and then fail to find two digits for the minutes.

    Frankly I’d be tempted to manually reformat the string before parsing so that it always ends in 4 digits instead of 3. Reluctant as I am to recommend them usually, this does sound like a job for regular expressions 🙂

    Just as an aside, I’m not sure why you’ve got both the “H” and “h” formats – it’s never going to match the second format, because anything valid for the second would have been valid for the first.

    If you fix up the string beforehand as I’ve suggested, you can then just use

    {"M d yyyy HHmm", "M d yyyy 0"}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Date that look like String, and I want parse it. But date
I have a few procedures that, for simplicity's sake, look like the following: public
I have an array of DateTime objects and need to use them as strings
I have the following wonderfully unreliable statement: string LastsuccessfuldownloadDateTime = 04.07.2009 19:21:36 DateTime myDate
I have a datetime column in db that I want to transform into a
I have a few procedures, for simplicity sake, look like the following: public string
I have several objects that look like this: class PhoneNumber { String getNumber(); String
I have a service that give me a date time string in the following
So I have a flashobject which I need to pass a formatted DateTime string
I have the following method: public object[] GetEventsByUser(DateTime start, DateTime end, string fullUrl) The

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.