![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
Try: WHERE hit_date >= GETDATE() - 2 -- Tom |
|
---------------------------------------------------- Thomas A. Moreau, BSc, PhD, MCSE, MCDBA SQL Server MVP Toronto, ON Canada . "John" <nothanks (AT) nope (DOT) com> wrote in message news:7JKdnbE0F6Nc-tjZRVn-uQ (AT) adelphia (DOT) com... Hi Everyone, I use the following to get records from the last two days in MySql: where date_entered <= curdate() and date_entered >= DATE_SUB(curdate(),INTERVAL 2 day) I'm looking to do the same in MS-Sql server but I'm just not getting it. I've got this so far which does not work: where hit_date <= GETDATE() and hit_date >= DATE_SUB(GETDATE(),INTERVAL 2 day) then I tried this: WHERE hit_date >= DATEDIFF(GETDATE(), (GETDATE()-2) Essentially, I need all records from the last two days. Any help or guidance in this matter would be greatly appreciated. -JohnyB |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
I use the following to get records from the last two days in MySql: where date_entered <= curdate() and date_entered >= DATE_SUB(curdate(),INTERVAL 2 day) I'm looking to do the same in MS-Sql server but I'm just not getting it. I've got this so far which does not work: where hit_date <= GETDATE() and hit_date >= DATE_SUB(GETDATE(),INTERVAL 2 day) then I tried this: WHERE hit_date >= DATEDIFF(GETDATE(), (GETDATE()-2) Essentially, I need all records from the last two days. |
#6
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |