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)
 Get Data by Condition

Author  Topic 

Carliviris
Starting Member

9 Posts

Posted - 2009-08-27 : 12:03:52
I wanna know how i can do for obtain registers in sql server 2005, that have this condition:

- DateF is a datetime field. I wanna select the registers with the same month and with same week.

Is this posible?

Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-08-27 : 12:36:03
yup just do like

SELECT * FROM YourTable WHERE DateF >= DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0) AND DateF <DATEADD(mm,DATEDIFF(mm,0,GETDATE())+1,0)

for current month data

and

SELECT * FROM YourTable WHERE DateF >= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0) AND DateF <DATEADD(wk,DATEDIFF(wk,0,GETDATE())+1,0)
for current week data
Go to Top of Page

cat_jesus
Aged Yak Warrior

547 Posts

Posted - 2009-08-27 : 12:36:17
please define registers in this context.



An infinite universe is the ultimate cartesian product.
Go to Top of Page
   

- Advertisement -