SELECT TRUNC ( CASE WHEN NEXT_DAY ( TO_DATE ( '20140301', 'YYYYMMDD' ), 1 ) - TO_DATE ( '20140301', 'YYYYMMDD' ) = 7 THEN ( ( TO_DATE ( '20140418', 'YYYYMMDD' ) - TO_DATE ( '20140301', 'YYYYMMDD' ) ) / 7 ) - 1 ELSE ( TO_DATE ( '20140418', 'YYYYMMDD' ) - TO_DATE ( '20140301', 'YYYYMMDD' ) ) / 7 END ) + 1 FROM DUAL