Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
satheesh
Posting Yak Master
152 Posts |
Posted - 2011-03-17 : 06:37:48
|
| Hi All,I need to add 1 year to startdate(date was in this formate yyyy-mm-dd in db ) to form a new startdate and then i need to change the date style.How to do both in one syntax.For Ex:one year to startdate -- dateadd(year,1,StartDate) as NewStartDate it returns 2012-03-24 00:00:00.000.here i need to convert again to display as 24/03/2012 this syntax will do the conversition - CONVERT(VARCHAR(10),XXXXX,103).How to combine both together.Any help would be highly appreciatedThanks.GS |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2011-03-17 : 06:40:32
|
| SELECT CONVERT(VARCHAR(10),dateadd(year,1,StartDate),103)Vaibhav TIf I cant go back, I want to go fast... |
 |
|
|
Ranjit.ileni
Posting Yak Master
183 Posts |
Posted - 2011-03-17 : 06:42:58
|
| Hi,check it onceselect getdate()--2011-03-17 16:11:51.770select CONVERT(VARCHAR(10),getdate(),103) --17/03/2011select dateadd(year,1,getdate())--2012-03-17 16:11:51.770select CONVERT(VARCHAR(10),dateadd(year,1,getdate()),103)--17/03/2012--Ranjit |
 |
|
|
satheesh
Posting Yak Master
152 Posts |
Posted - 2011-03-17 : 07:47:54
|
| Many thanks for both.Its working.Also i need to include hh:mm:ss:nnn in style conversistion.Now its displaying as 25/03/2011.How to include this.Thanks in advance.Regards,SG |
 |
|
|
|
|
|
|
|