I’m developing a web application and I’m using a gridview and sqldatasource.
I have some columns with type : Date.
In my control panel I set the format of the date for my country wich is : dd.mm.yyyy
- In this case , the Table Data of the database in c# will have the
format for date :dd.mm.yyyy
I’m planing to publish my website on a host when I’ll finish the project.
- But my question is :
If in my database the columns with Date are in format dd.mm.yyyy , if I publish the database and use it with the website on the host , the dates will be dd.mm.yyyy or converted to the default format of the host?
The dates stored in the database do not have a certain format. You chose, in your control panel, to show them with the format
dd.mm.yyyy, but that doesn’t change what’s really stored in the DB. They are similar toDateTimeobjects, representing a Date, not a string representing a date through a certain format. How the dates are turned into strings depends on what culture settings are used when converting it to a string, which in most cases (e.g.DateTime.ToShortDateString()) should be the current culture. If your code specifically said to use the formatdd.mm.yyyy, then that will need to change.So yes, it should be shown in the default format of the host.
(Side note: in .NET date-to-string formatting,
MMis month, andmmis minutes. You shouldn’t need to deal with this in this case, but take care that you use the correct one any time you do.)