Hi Aleks,
I’m sorry but I’m not 100% certain of what you require here, but I’ll have a go …
First off, it looks a little wrong, the BETWEEN clause you posted.
ADD_MONTHS works on DATE (in this case) data types. Yours looks to be working on a string - so this might be a better solution, also, the string literal has no time portion, so the time portion of the format string is not necessary - it defaults to 0 hours, 0 minutes and 0 seconds:
BETWEEN ADD_MONTHS(to_date(‘2015/08/31’, ‘yyyy/mm/dd’), -4) AND to_date(‘2015/08/31’, ‘yyyy/mm/dd’)
However, I get the impression that you do not want to be editing the code all the time, so you should use bind variables, or substitution variables, in Toad:
BETWEEN ADD_MONTHS(to_date(’&end_date_as_yyyymmdd’, ‘yyyymmdd’), -4) AND to_date(’&&end_date_as_yyyymmdd’, ‘yyyymmdd’)
You only have to type in the date as yyyymmdd, no quotes or ‘/’ separators etc are required. In Toad you will be prompted to supply two variables, but you need only supply the first with one ampersand, then click OK. The same value will be used for both. The ampersands have the following meaning:
&xxx = prompt me for a value for this variable and call it xxx.
&&xxx = do not prompt me, unless xxx has no current value, just use the existing value.
HTH