Apr-16-2020, 06:31 PM
Using mysql I can get this to work. I
want to get all missing days between 2 dates.
The table was last updated on 4-10-2020. Today is 4-16-2020
As of today below is the correct output.
python version 3.6.8
Any suggestions to get this to work in python ?
TIA
Steve42
want to get all missing days between 2 dates.
The table was last updated on 4-10-2020. Today is 4-16-2020
As of today below is the correct output.
Output: date field_id_id
2020-04-11 21
2020-04-12 21
2020-04-13 21
2020-04-14 21
2020-04-15 21
2020-04-16 21
Output:set @i = -1;
Select B.date, 21 as field_id_id
from (
SELECT DATE(ADDDATE('2020-03-18', INTERVAL @i := @i + 1 DAY)) AS date
FROM dummy
HAVING @i < DATEDIFF('2020-04-16', '2020-03-18')
)B left join (
Select date
from dummy
where field_id_id = 21
and date between '2020-03-18' and '2020-04-16'
)C
ON B.date = C.date
where C.date is NULL
-- Below is the python giving me an error on "Interval %s "v_sql_tx = 'Select B.date, %s as field_id_id '\ ' from ( '\ ' SELECT DATE(ADDDATE(%s, INTERVAL %s:= %s + 1 DAY)) AS '\ ' date '\ ' FROM dummy '\ ' HAVING %s < DATEDIFF(%s, %s) '\ ' )B left join( '\ ' Select date '\ ' from dummy '\ ' where field_id_id = %s '\ ' and date between %s and %s '\ ' )C ON B.date = C.date '\ ' where C.date is NULL '
python version 3.6.8
Any suggestions to get this to work in python ?
TIA
Steve42