Вопрос

I have a VB.net 2010 program, using MS personal SQL server (MSDE) version 2010, where a select statement is failing. The query works correctly from the query tester, and the program functions properly by using other queries.

The 'requestdate' entries are MM/DD/YYYY, or 1/22/2014 for a recent entry.

The SQL statement is:

Select count(*)  from Table 
WHERE (Closed = 'false') AND (requestdate < convert(date, GETDATE() - 3));

I am trying to get a count of entries that are between today and 2 days ago. There there is a simular query asking for 7 days.

Any help would be great. -Thanks

Это было полезно?

Решение 2

This is what fixed it:

Select count(*) from tablew WHERE (Closed = 'false') AND (datediff(dd,requestdate,getdate()) < 3)

Другие советы

try this:

Select count(*)  from Table 
WHERE (Closed = 'false') AND (requestdate < convert(date, GETDATE()-3));
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top