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 |
|
monfu
Yak Posting Veteran
81 Posts |
Posted - 2005-11-24 : 18:34:06
|
| Dear All,I am creating a report to get the last transaction done between today and the last 14 daysMy where clause is like this:-WHERE (date_posted >= GETDATE()) AND (date_posted <= GETDATE() - 14)for some reason its not working fineIs the syntax correct? |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-11-24 : 19:21:38
|
| WHERE (date_posted <= GETDATE()) AND (date_posted >= GETDATE() - 14)same asWHERE date_posted between GETDATE() - 14 and GETDATE()or you might wantWHERE date_posted between convert(varchar(8),GETDATE() - 14,112) AND convert(varchar(8),GETDATE(),112)if you are dealing with dates rather than datetimes==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
monfu
Yak Posting Veteran
81 Posts |
Posted - 2005-11-24 : 19:47:17
|
| oh thanks mate! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-11-25 : 00:18:42
|
| orWHERE date_posted between DateAdd(day,DateDiff(day,0,GETDATE() - 14),0) AND DateAdd(day,DateDiff(day,0,GETDATE()),0)MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|