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!


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.