INSERT dd/MM/yy format date without using CONVERT Function - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

INSERT dd/MM/yy format date without using CONVERT Function

simsimlhrsimsimlhr Posts: 2Member
I have made a software in dot net 2005 (c#) and insert date into the database using format MM/dd/yy format. Now requirement of the client suddenly change , he wants date in the format dd/MM/yy, i have change the regional setting of my computer and it changes the display of the format in the sql server but when we insert dd/MM/yyyy(25/3/2009) it gives error, is there any way out,
can we just change the setting of sql server 2000 and date is converted into dd/MM/yy???


  • DaiMitnickDaiMitnick Posts: 77Member
    Visual Studio's locality settings only ensure that data is displayed in the correct format for your region, the DateTime object absolutely always stores the date in mm-dd-yyyy format.

    If you want it in another format you either need to add code to the program accessing the sql databases to display it differently, or better still, convert the date into a formatted string before inserting into the database. In C# I believe the code for this is:

    string MyDate = DateToImport.ToString("dd/mm/yyyy");

    For reference, in I believe it would be:
    Dim MyDate as string = DateToImport.ToString("dd-mm-yyyy")

    Do or do not, there is no try. |
Sign In or Register to comment.