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 |
JTienter
Starting Member
1 Post |
Posted - 2008-10-13 : 17:15:48
|
Hi,I need to select records by date from within a five day window.I would like to use datediff to automatically get the current date and return everything from the current date to five days ago.I have tried and tried and have now gone insane. Any help would be greatly appreciated.Thankyou. |
|
hanbingl
Aged Yak Warrior
652 Posts |
Posted - 2008-10-13 : 17:48:03
|
[code]SELECT * from <YOURTABLE>where <DATECOLUMN> between DATEADD(dd,DATEDIFF(dd,5,GETDATE()),0) ANDDATEADD(dd,DATEDIFF(dd,0,GETDATE()),0)[/code] |
|
|
|
|
|