how to count distinct value per day with start time and end time
For MySQL 8+:

WITH RECURSIVE dates AS (
SELECT MIN(DATE(starttime)) `date` 
  FROM table1
UNION ALL
SELECT `date` + INTERVAL 1 DAY 
  FROM dates 
  WHERE `date` &lt; ( SELECT MAX(DATE(endtime)) 
                   FROM table1 )
),
users AS (
SELECT DISTINCT username 
  FROM table1
)
SELECT /* DISTINCT */ users.username, dates.`date`, 1 `count(*)`
FROM users
JOIN dates
JOIN table1 ON table1.username = users.username
           AND dates.`date` BETWEEN DATE(table1.starttime) 
                                AND DATE(table1.endtime)