Skip to content
Advertisement

how to get different date ranges for the last One year as per sysdate

I have a scenario: as per my sysdate i need to capture last 12 months dates.

Example: I will be getting a parameter which is numeric like : 2,3,4,6 ..

If the parameter is 3: then as per sysdate-12 i am expecting 4 records as below

Between two dates i have difference of 3 months. If the parameter is 2 then difference between Start_Date and End_Date should be 2 months which means i will be getting 6 records.

Can we write a query to read this numeric parameter and create records on the base of the parameter. Without writing multiple queries like above , is there any possibility i can read the parameter and create records

Advertisement

Answer

You can use the following query:

— With Input parameter as 2

— With Input parameter as 3

Cheers!!

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement