I have a table with date ranges like
----------------------------------------------------------------
| id | date_start | date_end |
----------------------------------------------------------------
| 1 | 2017-02-03 08:00:00.000 | 2017-02-03 17:00:00.000|
| 2 | 2017-02-04 15:00:00.000 | 2017-02-05 10:00:00.000|
| 3 | 2017-02-06 14:00:00.000 | 2017-02-07 23:00:00.000|
----------------------------------------------------------------
As you can see, some of the ranges can cover more than 1 day period (like #2, #3), and I need to separate such records by days to have a result like:
----------------------------------------------------------------
| id | date_start | date_end |
----------------------------------------------------------------
| 1 | 2017-02-03 08:00:00.000 | 2017-02-03 17:00:00.000|
| 2 | 2017-02-04 15:00:00.000 | 2017-02-04 23:59:59.999|
| 2 | 2017-02-05 00:00:00.000 | 2017-02-05 10:00:00.000|
| 3 | 2017-02-06 14:00:00.000 | 2017-02-06 23:59:59.999|
| 3 | 2017-02-07 00:00:00.000 | 2017-02-07 23:00:00.000|
----------------------------------------------------------------
How can I do it with SQL on Redshift?