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 |
|
hameedf
Starting Member
27 Posts |
Posted - 2012-08-06 : 05:06:48
|
| Hello expert !I want add previous 6 days in current date. If i run a query it get the data of current date + previous 6 days?----Last Day of Last WeekSELECT DATEADD(wk,DATEDIFF(wk,7,GETDATE()),6)----Last Day of Current WeekSELECT DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6) Thanks hfHameed |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2012-08-06 : 05:08:30
|
SELECT * FROM dbo.Table1 WHERE Col1 >= DATEADD(DAY, -6, GETDATE()) N 56°04'39.26"E 12°55'05.63" |
 |
|
|
hameedf
Starting Member
27 Posts |
Posted - 2012-08-06 : 05:19:32
|
| Swepeso thank for your reply how to set in below set? Set @StartDate = Case When @StartDate = '1900-01-01' Then DateAdd(dd, DateDiff(dd,0,GetDate()-7), 0) Else @StartDate End;Thanks hfHameed |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2012-08-06 : 08:11:26
|
[code]DECLARE @StartDate DATETIMESET @StartDate = CASE @StartDate WHEN '19000101' THEN DATEDIFF(DAY, '19000108', GETDATE() ELSE @StartDate END;[/code] N 56°04'39.26"E 12°55'05.63" |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|
|