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 |
|
tantcu
Yak Posting Veteran
58 Posts |
Posted - 2012-06-29 : 14:36:35
|
| I tried to get this date: 2009-06-01I used the code : CONVERT(CHAR(8), DATEADD(YY, -3, getdate()),112)The result is 20090629.Is there anyone know how to fix?Thanks |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
sshelper
Posting Yak Master
216 Posts |
Posted - 2012-06-30 : 03:25:51
|
| Here's a couple of links that shows how to format a DATETIME value to the different date formats:http://www.sql-server-helper.com/tips/date-formats.aspxhttp://www.sql-server-helper.com/sql-server-2008/sql-server-2008-date-format.aspxSQL Server Helperhttp://www.sql-server-helper.com/tips/tip-of-the-day.aspx |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-07-01 : 01:02:03
|
quote: Originally posted by tantcu I tried to get this date: 2009-06-01I used the code : CONVERT(CHAR(8), DATEADD(YY, -3, getdate()),112)The result is 20090629.Is there anyone know how to fix?Thanks
is database field type date or varchar?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2012-07-02 : 04:09:24
|
| Start with this select dateadd(year, -3, getdate()-day(getdate())+1)MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|