Click here to Skip to main content
15,893,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my sql server date format is like this 'dd/mm/yyyy'. But I want to change british format 'mm/dd/yyyy' . how to change it .

Please help me
Posted

You don't. You can't. The only way to translate a DateTime into a specific format is to convert it to a VARCHAR or other "string" data type. This means that it is no longer a DateTime. It is a VARCHAR.

Here is the code to convert into 'mm/dd/yyyy' format:
SQL
select right('0' + rtrim(month(@d)),2) + '/' + right('0' + rtrim(day(@d)),2) + '/' + rtrim(year(@d)).
 
Share this answer
 
You should always store dates as DATETIME variables, and only use strings when displaying, as suggested here[^].
 
Share this answer
 
hi,
use following,

SQL
SELECT CONVERT(NVARCHAR(12),GETDATE(),101)


hopes this might be useful for u...
 
Share this answer
 
v2
Comments
ProEnggSoft 17-Mar-12 8:41am    
Edit: pre tag for SQL code added - PES
[no name] 17-Mar-12 9:47am    
what?
irfanansari 19-Aug-19 4:39am    
if we use this just date show in good format but when we comparison between two diffrence date then it again required format like yyyy-mm-dd it is not work as like dd-mm-yyyy
Hello,

You Can Use Select Convert(varchar, getdate(), 1) Hope this will help you..
 
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