Link to home
Start Free TrialLog in
Avatar of faith0999
faith0999

asked on

How can I get the month-to-date in SQL?

How can I get the month-to-date?( for everytime this query is ran it will need to return the count of cases for only the current month and not any of the previous months.) Please advise.

This is my current query:
SELECT         trunc(sysdate,'mon') current_dt
        ,Count(*) Count
FROM pda_main
WHERE result_d BETWEEN TO_DATE('04/01/2006', 'MM/DD/YYYY')
 AND TO_DATE ('12/31/2006', 'MM/DD/YYYY')
GROUP BY        sysdate

This is the return I receive:(below) but if I change the start date in my where statement for result_d to 3/01/2006, it will give me that months data and the current month but I only want the current's month data.

current_dt  | count
4/1/2006    |   21
ASKER CERTIFIED SOLUTION
Avatar of MikeOM_DBA
MikeOM_DBA
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of faith0999
faith0999

ASKER

okay, that works. thank you and have a wonderful day! :)