websss
asked on
sql date +14 days
i need to filter data on the last 14 days
the code would be something like
what code would be correct for this
the data type is date2
the code would be something like
Select 06-07, 07-08, 08-09 from UsageLogs where BranchId = 54 AND reportDate between now + 14 days
what code would be correct for this
the data type is date2
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Basically you wan all the records from the table that have a ReportDate in the last 14 days from right now, which means the ReportDate is greater than right now minus 14 days:
Select
06-07, 07-08, 08-09
from
UsageLogs
where
BranchId = 54
AND reportDate > DATEADD(dd,-14, getdate())
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://technet.microsoft.com/en-us/library/ms186819.aspx
Open in new window
Should do the trick - between "now" and "14 days ago"