Pages

Monday, September 17, 2018

How to get current month records since first date in database query?

To get the records for the current month since day one of current month you may use the below where clause.




DB2:

WHERE ENTERED_DATE BETWEEN CURRENT DATE - (DAY(CURRENT DATE) - 1) DAYS AND CURRENT DATE;

or

WHERE ENTERED_DATE BETWEEN SYSDATE - (DAY(SYSDATE) - 1) DAYS AND SYSDATE;

Oracle:

WHERE ENTERED_DATE BETWEEN TRUNC(SYSDATE, 'mm') AND SYSDATE;

or

WHERE ENTERED_DATE BETWEEN TRUNC(SYSDATE, 'month') AND SYSDATE;

No comments:

Post a Comment