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 2005 Forums
 Transact-SQL (2005)
 Date = This week?

Author  Topic 

cipriani1984
Constraint Violating Yak Guru

304 Posts

Posted - 2009-09-22 : 05:00:59
Hi,

Ive got a table of transactions, any ideas/instructions on how to write logic to show only those records for the current week in the year?

Cipriani

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-22 : 05:03:18
General way

where datecol>=dateadd(week,-1,getdate())

If it doesn't give the data you want, define what current is for

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

cipriani1984
Constraint Violating Yak Guru

304 Posts

Posted - 2009-09-22 : 05:09:27
Hi

Thanks for your prompt reply, Ive just run your query and it is giving me records from the 16th last week.

Anyway of giving from current monday to sunday etc?

Thanks

#
quote:
Originally posted by madhivanan

General way

where datecol>=dateadd(week,-1,getdate())

If it doesn't give the data you want, define what current is for

Madhivanan

Failing to plan is Planning to fail

Go to Top of Page

cipriani1984
Constraint Violating Yak Guru

304 Posts

Posted - 2009-09-22 : 05:15:59
Sorry ignore the last post, thats great thanks!

quote:
Originally posted by madhivanan

General way

where datecol>=dateadd(week,-1,getdate())

If it doesn't give the data you want, define what current is for

Madhivanan

Failing to plan is Planning to fail

Go to Top of Page
   

- Advertisement -