Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I inserting a date in the format of 'dd/MM/yyyy'.But in database it is storing in the following format 'MM/dd/yyyy'.how should i solve this pblm?
Posted

Date will always be stored in MM/dd/yyyy format in sql server. If you want it in dd/MM/yyyy format try converting it.
For example
SQL
SELECT convert(varchar, getdate(), 103)  --dd/mm/yyyy


Check out
How to format datetime & date in Sql Server 2005[^]
SQL Server Date Formats[^]
 
Share this answer
 
The best ways is keep date column datatype as datetime and whenever you want to retrieve data from database then you can fetch in different format for ex. you can also try some other no. also
SQL
SELECT convert(varchar, getdate(), 103)<pre lang="sql">--08/01/2013 --dd/MM/yyyy
SELECT convert(varchar, getdate(), 105) --08-01-2013 --dd-MM-yyyy
SELECT convert(varchar, getdate(), 109) --Jan  8 2013  2:24:17:140PM</pre>
 
Share this answer
 
v2
You don't. If you store it as a date, then what you see is a rendering detail, the database is not using any format at all, it's just showing it in a format when it shows it, based on the locale of the server. If your server is in the US and you want to show dd/mm/yyyy, use the ToString method on the DateTime class to change the format in the place that makes sense, the presentation layer.
 
Share this answer
 
Not a problem. While displaying in asp.net web page, you need to change the format.
You can try this:
C#
Label1.Text = DateFromDataBase.ToString("dd/MM/yyyy");



--Amit
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900