mysql - Convert table with date range into list of dates -


this question has answer here:

i have table called daterange looks this

|id|datestart|  dateend| | 1|14-may-14|16-may-14| | 1|20-may-14|21-may-14| | 2|20-may-14|21-may-14| 

which convert following format in table called datelisted

|id|     date| | 1|14-may-14| | 1|15-may-14| | 1|16-may-14| | 1|20-may-14| | 1|21-may-14| | 2|20-may-14| | 2|21-may-14| 

i have reviewed following question, convert date range individual days, however, data different hoping assist me?

thanks.

if have utility table of dates, it's easy...

drop table if exists my_table;  create table my_table (id int not null  ,datestart date not null ,dateend date not null ,primary key(id,datestart) );  insert my_table values (1,'2014-05-14','2014-05-16'), (1,'2014-05-20','2014-05-21'), (2,'2014-05-20','2014-05-21');  select * my_table; +----+------------+------------+ | id | datestart  | dateend    | +----+------------+------------+ |  1 | 2014-05-14 | 2014-05-16 | |  1 | 2014-05-20 | 2014-05-21 | |  2 | 2014-05-20 | 2014-05-21 | +----+------------+------------+  select x.id      , c.dt date    calendar c    join my_table x      on c.dt between x.datestart , x.dateend   order       id      , date; +----+------------+ | id | date       | +----+------------+ |  1 | 2014-05-14 | |  1 | 2014-05-15 | |  1 | 2014-05-16 | |  1 | 2014-05-20 | |  1 | 2014-05-21 | |  2 | 2014-05-20 | |  2 | 2014-05-21 | +----+------------+ 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -