I am currently trying to get the number of months between 2 dates in Oracle SQL, however when the end date is null then it comes up with null, is there a way to use todays date if end date is null in the select statement?
I have tried the months_between statement, but I am unsure how to handle the null value. If the end date is blank i would like the "months from start" to calculate is as if it was today my current code in select statement is - trunc(months_between(START_DATE,END_DATE)) as "Months From Start"
My expectation would be the "months from start" column would return -4
Use NVL function (or CASE, or DECODE, ... whichever you find appropriate), e.g.
BTW, there are 16 months between August 2022 and today (December 2023), not 4.