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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 last week

Author  Topic 

stausif
Starting Member

5 Posts

Posted - 2012-06-22 : 22:18:25
Hi..


i tried this one, it's showing the data of last week.

select Max(Week(COLNAME) ) from table_name
But I want to display the data from Monday 12 to sunday 23:59 that is last week..

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-06-22 : 22:42:28
[code]
SELECT *
FROM table
WHERE COLNAME >= DATEADD(dd,((DATEDIFF(dd,0,GETDATE())/7)-1)*7,0)
AND COLNAME < DATEADD(dd,(DATEDIFF(dd,0,GETDATE())/7)*7,0)
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -