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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:07:39+00:00 2026-06-13T10:07:39+00:00

My Code: DateTime? birthDate = DateTime.Parse(filterDictionary.ContainsKey(DOB) ? filterDictionary[DOB] : string.Empty); I am getting Error

  • 0

My Code:

DateTime? birthDate = DateTime.Parse(filterDictionary.ContainsKey("DOB") ? filterDictionary["DOB"] : string.Empty);

I am getting Error Message as “String was not recognized as a valid DateTime.” How to solve this issue. 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-06-13T10:07:40+00:00Added an answer on June 13, 2026 at 10:07 am

    The problem (at least one of them) is that you can’t parse an empty string to a DateTime.

    Change your line of code to this to move the parsing only when you find the key, and return null instead of parsing when you don’t have it:

    DateTime? birthDate = filterDictionary.ContainsKey("DOB") ? DateTime.Parse( filterDictionary["DOB"]) : (DateTime?) null;
    

    The other problem might be that your dictionary DOB value is actually not possible to convert to a DateTime. If the above code does not work, please edit your question and post the value in filterDictionary["DOB"] when you get this error.

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

Sidebar

Related Questions

I am getting a date from server side C# using the following code: DateTime
In Python I have this code: now = datetime.now().isoformat() if . not in now:
Using the example code included in the man page for DateTime::Astro::Sunrise , I'm getting
This line of code: DateTime dt = DateTime.ParseExact(time, hh:mm, CultureInfo.InvariantCulture); parses a time value
Here's my code: DateTime date1 = new DateTime(byear, bmonth, bday, 0, 0, 0); DateTime
My code: import datetime as dt import scikits.timeseries as ts ts_start_datetime= ts.Date(freq='T',year=2011,month=1,day=1,hour= 0,minute=0) ts_end_datetime
Here is my code: a.dateFrom = DateTime.ParseExact(x, dd/mm/yyyy, null); And x has value of:
Here is my code: partial void OnisApprovedChanging(bool value) { this.dateApproved = DateTime.Now; } 'dateApproved'
In this C# code snippet, DateTime.Now.Month.ToString() returns 7 as output. I would like to
i have the following code def get(self): date = datetime.date.today() loc_query = Location.all() last_cursor

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.