I have a dataset with two date columns: start_date and last_invoice_date for each client. I would like to generate a list of the months between these two dates (not the number of months, but the actual month names).
For example, if I have:
client start_date last_invoice_date
A Mar 1, 2020 Jun 1, 2020
B January 10, 2018 May 10, 2020
I´d like to see this:
client start_date last_invoice_date date
A Mar 1, 2020 Jun 1, 2020 Mar 2020
A Mar 1, 2020 Jun 1, 2020 Apr 2020
A Mar 1, 2020 Jun 1, 2020 May 2020
A Mar 1, 2020 Jun 1, 2020 Jun 2020
........ Same for client B and so on.
I´m trying this in sql dataflow, but I kow the logic is wrong.
SELECT a.*, DATE_ADD(`start_date`, INTERVAL @i:=@i+1 MONTH) AS 'Date'
FROM `table` a
, (SELECT @i=0) b
HAVING @i< PERIOD_DIFF(`last_invoice_date`,`start_date`)
Is there another approach worth a try?