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 |
|
satheesh
Posting Yak Master
152 Posts |
Posted - 2011-10-04 : 11:56:34
|
| Dear All,I try to write a query to pull all records where the expiry date is 5 days from current date.On the WHERE clause I added:WHERE polciy.expirydate <= GETDATE()+5. but not working, i also tried WHERE polciy.expirydate <= dateadd(day, 5, dateadd(day, datediff(day, 0, getdate()), 0))Not brings the desired resultI need all record that will expries on for eg 09.10.2011(5days from today)How to amend the above query.Any help is highly appreciated.Thanks,SG |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-04 : 12:00:36
|
| [code]WHERE polciy.expirydate >= DATEADD(dd,DATEDIFF(dd,0,GETDATE())+5,0)AND polciy.expirydate<DATEADD(dd,DATEDIFF(dd,0,GETDATE())+6,0)[/code]will give you all records that will expries on 09.10.2011------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
satheesh
Posting Yak Master
152 Posts |
Posted - 2011-10-04 : 12:08:05
|
| Thank You visakh.Its working.. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-04 : 12:21:29
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|