Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,

i want to use "dd/MM/yyyy" format in my project so i changed it into sql display format and on my server and on iis7 LCID to English UK but sql server still use format "MM/dd/yyyy" so
Posted

select convert(varchar,date,103) as date from tablename


use it while fetching data from sql server.
 
Share this answer
 
Comments
uttam2010 20-Jun-11 1:23am    
try to <%#DataBinder.Eval(Container.DataItem, "Yrdatecolumn", "{0:dd/MM/yyyy}").ToString()%>
Sql doesn't care about format unless you're returning the DateTime 's value as a string instead of a DateTime (you should generally avoid returning a DateTime as anything but a DateTime). The front end is where you control the format (how it's displayed). You can do that like this:

C#
// globally accessible culture object
using System.Threading;

System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
 
Share this answer
 
v4
In sql it takes mm/dd/yyyy. But in code you can change it. like,0 string dt=DateTime.Now.ToString("dd/MM/yyyy");
 
Share this answer
 
Add following under web.config <system.web>

<globalization culture="en-GB"/>
 
Share this answer
 
Comments
mohammed sadeq 20-Jun-11 2:26am    
thanks for all,
i send format correctly to sql as dd/MM/yyyy but it change it to format MM/dd/yyyy

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