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 |
|
jigsatics
Starting Member
18 Posts |
Posted - 2006-01-11 : 13:11:00
|
| Hi!I have a DB with this fields:MID - primary keyEVENT - varchar(2)EVENT_DATE datetime (format mm/dd/yyyy)I need to design a query that will pickup records from DB with EVENT = '02' and EVENT_DATE equal or earlier than 18 days from the date the query was executed.In this example, the query should display these 2 records if ran today:MID EVENT EVENT_DATE01 02 12/25/2005 02 02 12/20/2005 But not this:MID EVENT EVENT_DATE03 03 12/25/2005 04 02 01/01/2006Any help will be greatly appreciated.$3.99/yr .COM!http://www.greatdomains4less.com |
|
|
nosepicker
Constraint Violating Yak Guru
366 Posts |
Posted - 2006-01-11 : 20:04:31
|
| SELECT mid, event, event_date FROM YourTable WHERE event = '02' AND event_date <= DATEADD(d, DATEDIFF(d, 0, getdate()) -17, 0) |
 |
|
|
|
|
|