Why saving worng date in sqldatabase RRS feed

  • Question

  • i am using c# to save date in custom fromat dd/MM/yyyy from datetimepicker propertis. but it is saving MM/dd/yyyy in is saving wrong values of data and month i can't understand why? but when i save the date as 2018/03/15, it is saved as 2018/15/03.when i want to see a report, it works when i enter day as month and month as day.i don't understand why date is saving in wrong format while my datetimepicker shows right can i solve this problem.Please help

    What I have tried:

    changed date customformat many times in datetimepicker propertis.but it did not work
    Monday, April 9, 2018 9:31 AM

All replies

  • May This Help You

    You need to configure SQL Server & OS

    Take a look at

    OS Settings can be changed at

    Control Panel\Clock, Language, and Region\Change Date,time or number formats

    For SQL server
    In the Object explorer of SQL server-->Select server & right click-->properties-->advanced-->default language

    Monday, April 9, 2018 9:45 AM
  • Hello,

    Let me repeat what I said in your other post.

    Dates are stored in a database according to the locale and formatting is the responsibility of the developer when retrieving data out of the database table. Similarly, you can't store a currency symbol for a decimal type in a database, data is stored raw and the formatting is the developer's responsibility.

    Here is an example for SQL-Server, the first shows Birthday as saved in the database while the second and third are custom formatted on the exact same column. 

    Not what I would do as the above provides the reasoning.


    So in conclusion, dates are stored to the locale of the installed instance of your SQL-Server and you the developer are responsible for formatting in your application. The formatting in the image above is for demonstration only. If you were to display a date from a table in a DateTimePicker you would set the format there.

    Changing the culture for the application is not the way to go either.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Monday, April 9, 2018 11:32 AM