Reputation: 5326
I am using DB2. I want to know the number of applications (Records/row) since the last seven days including today and my date column is ReceivedDate.
I basically want to write a query that intents to do the following: (DB2), please help me.
Select count(*) from Applications WHERE ReceivedDate is within 7 days
Upvotes: 1
Views: 157
Reputation: 37473
You can try below -
Select count(*) from Applications
WHERE ReceivedDate>CURRENT DATE - 7 Days and ReceivedDate<=CURRENT DATE
Upvotes: 2
Reputation: 522040
Try this query, which uses CURRENT DATE
:
SELECT COUNT(*)
FROM Applications
WHERE ReceivedDate > CURRENT DATE - 7 DAY;
This answer assumes that a received date would never be in the future (since it can't have yet happened).
Upvotes: 3