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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:57:00+00:00 2026-05-15T23:57:00+00:00

I have used a textbox to store a date in DD-MM-YYYY format and since

  • 0

I have used a textbox to store a date in DD-MM-YYYY format and since i use SQL server i used to get the value from the textbox and then place it in a variable of type DateTime dt

DateTime dt = DateTime.ParseExact(TextBox10.Text,"MM-DD-YYYY",CultureInfo.InvariantCulture);

I am getting format specification error, I went through many documentation but still couldn’t get where i am going wrong

This i am using C# and ADO.net
Please can anyone correct me?

  • 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-15T23:57:01+00:00Added an answer on May 15, 2026 at 11:57 pm

    It looks like you mixed up DD and MM. Try below:

    DateTime dt = DateTime.ParseExact(TextBox10.Text,"dd-MM-yyyy",CultureInfo.InvariantCulture);
    

    Notice that I changed “DD” to “dd”!

    UPDATE:

    Ok, so I changed “YYYY” to “yyyy” and ran the code below and it parsed sucessfully:

    DateTime dt = DateTime.ParseExact("28-01-2010", "dd-MM-yyyy", provider);
    

    If your users really are passing in dates in the format “dd-MM-yyyy” this should work for you. Keep in mind that the second string has nothing to do with whatever format you are storing in your database. It only has to do with the format of the first string argument in ParseExact. HTH.

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

Sidebar

Related Questions

say I have a textBox and a property to get and set its value:
I have used auto complete textbox previously. That auto complete works only when i
I have used the following template in my project: <DataTemplate x:Key=textBoxDataTemplate> <TextBox Name=textBox ToolTip={Binding
I have a TextBox in my application, that it is used for showing state
I have a textbox which accepts Minutes. This value will be stored in a
HI i had manullay created textbox's and then used it for creating a new
I have a textbox in a formview that gets its data from a linqdatasource
I have a textbox used to search for products. This textbox is placed in
I have used a regex function on a textbox, but it's not working. <input
I have used a rich textbox control,ckeditor in my case,When any formatting is done

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.