I'm also trying to split a row by 24 hours period ranges between FromDate
, Todate
.
For example, if a time row has given as below, (Range between FromDate
, Todate
is 4 days, so I want 4 rows)
ID---FromDate---Todate
1---2014-04-01 08:00:00.000---2014-04-04 12:00:00.000
The result I want to see would be like this:
ID---FromDate---Todate---DateDiff(HH)
1---2014-04-01 08:00:00.000---2014-04-01 23:59:59.000---15
1---2014-04-02 00:00:00.000---2014-04-02 23:59:59.000---23
1---2014-04-03 00:00:00.000---2014-04-03 23:59:59.000---23
1---2014-04-04 00:00:00.000---2014-04-04 12:00:00.000---12
I have found a solution to this, but it just does not work using Redshift when I iterate inside my own auxiliary table (different from the solution using SQL Server!)
I am not sure if this could be possible using Redshift or if I should look for another way to solve it (like a custom function or something like that).
Thanks!