I want to loop and print end of month date between two dates.

I have below code but it prints day on day.

```
startdate='2021-01-01'
enddate='2021-04-01'

enddate=$( date -d "$enddate + 1 day" +%Y%m%d )   # rewrite in YYYYMMDD format
                                                  #  and take last iteration into account
thedate=$( date -d "$startdate" +%Y%m%d )
while [ "$thedate" != "$enddate" ]; do
    printf 'The date is "%s"\n' "$thedate"
    thedate=$( date -d "$thedate + 1 days" +%Y%m%d ) # increment by one day
done

```

but I want these result for:

```
  startdate='2021-01-01'
    enddate='2021-04-01'

```

> 
> 20210131
> 
> 
> 

> 
> 20210228
> 
> 
> 

> 
> 20210331
> 
> 
> 

thanks in advance