SQLTeam.com | Weblogs | Forums

Date range


#1

I need to find data from a past date range. I will have the report run in December but would like the range be from 6/1/15-6/30/15.

I've tried this for the last day of the month but it doesn't seem to work if there are 30 days a month

SELECT TO_DATE(TO_CHAR(ADD_MONTHS(SYSDATE, -5), 'MM')|| '/' ||TO_CHAR(LAST_DAY(ADD_MONTHS(SYSDATE,-1)), 'DD')|| '/' ||TO_CHAR(ADD_MONTHS(SYSDATE,-1), 'YYYY'), 'MM/DD/YYYY')
FROM DUAL;


#2

Are you using Oracle? This is a MS SQL Server site.