Q:

How to make single array in between dates

I have one table called task
id          t_title              t_started_on               t_due_on
 1           Test 1           2018-01-18 01:00 PM            2018-01-20 01:00 PM
 2           Test 2           2018-01-25 01:00 PM            2018-01-27 01:00 PM

from here i have to select dates like first row start date is 2018-01-18 01:00 PM (t_started_on) and end date is 2018-01-20 01:00 PM(t_due_on).total is 3 days

2018-01-18
2018-01-19
2018-01-20

same as second row also 3 days

2018-01-25
2018-01-26
2018-01-27

Expected Result
    Array
(
    [allocatedDate] => 2018-01-18
    [allocatedDate] => 2018-01-19
    [allocatedDate] => 2018-01-20
    [allocatedDate] => 2018-01-25
    [allocatedDate] => 2018-01-26
    [allocatedDate] => 2018-01-27
)

How to write a select query in above case?

A:

Like I said in your previous question, you should not store your dates as strings, but in date datatype: that will make your data less error prone and your queries simpler. Now you'll have to convert those strings to dates each time you need to do date/time calculations with them.
To generate the dates inside periods, you need a helper table, which can be useful also for many other purposes: a table with one column that has natural numbers starting from 0 up to some large n. You could create it like this:
create table nums (i int);
insert into nums values (0), (1), (2), (3);
insert into nums select i+4 from nums;
insert into nums select i+8 from nums;
insert into nums select i+16 from nums;
insert into nums select i+32 from nums;
insert into nums select i+64 from nums;
insert into nums select i+128 from nums;
insert into nums select i+256 from nums;

You can see how you double the number of records by adding a similar insert statement, but this will already generate 512 records, which would be more than enough for your purposes: it should have the highest number of days that a period can have in your tasks table.
Then you can use this query to get the desired output:
SELECT DISTINCT date_add(d_started_on, interval i day)
FROM   (
        SELECT date(STR_TO_DATE(t_started_on, '%Y-%m-%d')) as d_started_on,
               datediff(
                   date(STR_TO_DATE(t_due_on, '%Y-%m-%d')),
                   date(STR_TO_DATE(t_started_on, '%Y-%m-%d'))
               ) as days
        FROM   tasks
       ) as base
INNER JOIN nums ON i <= days
ORDER BY 1

See also SQLfiddle

