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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:16:29+00:00 2026-06-10T04:16:29+00:00

I have a textbox with date format dd/MM/yyyy that I want to convert to

  • 0

I have a textbox with date format dd/MM/yyyy that I want to convert to the format yyyy-MM-dd to insert it into a database.

I tried

Convert.DateTime/DateTime.ParseExact 

but it always give me the system’s default date format.

I don’t know any other method to convert it in C#…

  • 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-10T04:16:31+00:00Added an answer on June 10, 2026 at 4:16 am

    You shouldn’t be converting it to a string at all to insert it into your database. (I’m surprised at all the other answers which are recommending this approach.)

    Instead, you should be using parameterized SQL, and set the value of the parameter to the DateTime value you’ve got. You should be using parameterized SQL anyway to avoid SQL injection attacks, and to keep your code and data separate. The fact that it avoids unnecessary string conversions (each of which is a potential pain point) is yet another benefit.

    This part of your question suggests you’ve got a fundamental misconception:

    I used Convert.DateTime/DateTime.ParseExact it always give me system date format.

    Those methods will give you a DateTime. A DateTime doesn’t have a format. When you call ToString you just get the default format for the current culture, but that’s not part of the value. It’s like with numbers – 16 and 0x10 are the same number, and the int doesn’t “know” whether it’s in decimal or hex; it’s a meaningless concept.

    All of this goes beyond your immediate problem, towards trying to keep your code base clean in terms of types. You should keep data in its most appropriate form for as much of the time as you possibly can, and make sure you understand exactly what that data means at all points. Conversions to other types (such as strings) for communication should be done only at API/system boundaries, and avoided even there if possible (e.g. using parameterized SQL as in this case).

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

Sidebar

Related Questions

I have a textbox containing a date in the format dd.MM.yyyy. Now I want
I have used a textbox to store a date in DD-MM-YYYY format and since
I have a textbox for entering date.Textbox should allow only dd/MM/yyyy format.How can i
I have a start date value to be entered in a textbox in dd/mm/yyyy
I have a datepicker which shows date in format dd/MM/yyyy(i know i coould change
I have a date column in a DB tabel that I want to query
I have datetime in one simple textbox. The format of the textbox's value can
I have a jquery datepicker that formats the date in dd/mm/yyyy. I need to
I have a macro which I specify the date (in mm/dd/yyyy) in a textbox
Higuys, I have a Textbox where user choose a date (MM/dd/yyyy) and another TextBox

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.