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 |
|
chandusama
Starting Member
13 Posts |
Posted - 2008-01-21 : 21:02:25
|
| hi guyz...this is my first doubt here as i have taken up an sql server course this semesteri am finding it tuff with one particular query...can sum one help me with this18. Generate a recordset of all people whose birthday falls within +/- two weeks from whenever the query is run.Sama |
|
|
singularity
Posting Yak Master
153 Posts |
Posted - 2008-01-21 : 21:29:38
|
| Use the datediff function. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-22 : 00:41:56
|
| where birthday>=dateadd(week,-2,dateadd(day,datediff(day,0,getdate()),0)) and birthday<=dateadd(week,2,dateadd(day,datediff(day,0,getdate()),0))MadhivananFailing to plan is Planning to fail |
 |
|
|
chandusama
Starting Member
13 Posts |
Posted - 2008-01-22 : 01:46:44
|
quote: Originally posted by madhivanan where birthday>=dateadd(week,-2,dateadd(day,datediff(day,0,getdate()),0)) and birthday<=dateadd(week,2,dateadd(day,datediff(day,0,getdate()),0))MadhivananFailing to plan is Planning to fail
thanks verymuch madhivanan....the query worked...thanks againSama |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|
|
|
|
|