Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
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 dataand 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
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.