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 |
|
mrjack
Yak Posting Veteran
50 Posts |
Posted - 2006-07-11 : 04:49:34
|
| Hi all..its kinda hard for me hw to figure out this, hopefully any of u guys can help me out with this super simple problem..here is my query..select convert(char(50),dateadd(day,-7,getdate()),105)its because i want it to look last week data. BUT i get the format like this '03-07-2006'what i want is it to be like this '20060703' how do i do that? Thanks,Jack |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-07-11 : 04:56:19
|
quote: Originally posted by mrjackwhat i want is it to be like this '20060703' how do i do that?
Jack, try this....select convert(char(50),dateadd(day,-7,getdate()),112) Harsh AthalyeIndia."Nothing is Impossible" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-07-11 : 04:57:25
|
| No need for conversion and Formation. Try thisSelect columns from yourTablewhere Datecol>=DateAdd(day, DateDiff(day,0,Getdate()),-7)MadhivananFailing to plan is Planning to fail |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-07-11 : 09:21:01
|
Are you storing date in string (char/varchar) data type or datetime data type ? KH |
 |
|
|
|
|
|
|
|