Get last day 3 months ago

Database
Enthusiast

Get last day 3 months ago

Hi,

Just wanted to help out someone if you needed help on this:-

1. To find the last day's date before 3 months from today

2. To find the first day's date before 3 months from today

SELECT
ADD_MONTHS(CURRENT_DATE,-3)- EXTRACT( DAY FROM ADD_MONTHS(CURRENT_TIMESTAMP(3),-3)) +1 AS "First Day 3 months before"
,ADD_MONTHS(ADD_MONTHS(CURRENT_DATE,-3)- EXTRACT(DAY FROM ADD_MONTHS(CURRENT_DATE,-3))+1, 1) - 1 AS "Last Day 3 months before"

You are welcome!

Regards,

SS