The below SQL gives the next Saturday and the next Sunday dates.
SELECT NEXT_DAY('06-MAR-2012', 'SATURDAY') "next saturday"
,NEXT_DAY('06-MAR-2012', 'SUNDAY') "next sunday"
FROM dual;
If the requirement is to find the previous weekend dates, just subtract the dates by 7.
SELECT NEXT_DAY('06-MAR-2012', 'SATURDAY')-7 "next saturday"
,NEXT_DAY('06-MAR-2012', 'SUNDAY')-7 "next sunday"
FROM dual;
SELECT NEXT_DAY('06-MAR-2012', 'SATURDAY') "next saturday"
,NEXT_DAY('06-MAR-2012', 'SUNDAY') "next sunday"
FROM dual;
If the requirement is to find the previous weekend dates, just subtract the dates by 7.
SELECT NEXT_DAY('06-MAR-2012', 'SATURDAY')-7 "next saturday"
,NEXT_DAY('06-MAR-2012', 'SUNDAY')-7 "next sunday"
FROM dual;
No comments:
Post a Comment