Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am unable to get date result in dd/mm/yyyy format when I add some days to
getdate(). I tried using:

string updateSql1 = "UPDATE txfile " + "SET expiry_dt=getdate() + 180 ";


Can anyone help me out to get result in dd/mm/yyyy.
Posted
Comments
Sanjay K. Gupta 1-Nov-12 8:20am    
your update command is wrong. correct may be
string updateSql1 = "UPDATE txfile " + "SET expiry_dt=DateAdd(dd,180,getdate())";

Try this

SQL
SELECT CONVERT(VARCHAR(10), GETDATE(), 103) AS [DD/MM/YYYY]
 
Share this answer
 
v2
SQL
SELECT CONVERT(VARCHAR(10), GETDATE()+ 180, 103) as [dd-MM-yyyy]  --> dd/MM/yyyy
--OR--
SELECT CONVERT(VARCHAR(10), GETDATE()+ 180, 105) as [dd/MM/yyyy]  --> dd-MM-yyyy

Underlined portion is optional
Happy Coding!
:)
 
Share this answer
 
Comments
fjdiewornncalwe 1-Nov-12 9:47am    
I must admit I've never seen the + 180 like this. Could you expand or provide a link as to what it does there?

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