Hi All,
I want to split date ranges to multiple rows of dates.
Source data:
Date_toDate_fromMaterial20-Aug-1622-Aug-1610019-Aug-1620-Aug-16200I need to transform this to the below structure.
DateHeader 220-Aug-1610021-Aug-1610022-Aug-1610019-Aug-1620020-Aug-16200Can you please suggest how to achieve this?
Thanks,
Shyam
Why not just using what HANA provides out of the box. There is the table _SYS_BI.M_TIME_DIMENSION which can be filled with date information (Generate Time Data - SAP HANA Developer Guide for SAP HANA Studio - SAP Library).
Then you can simply join your table against the standard table.
The select
select t2.date_sql, t1.material from <yourTable> as t1 inner join _sys_bi.m_time_dimension as t2 on t1.date_from <= t2.date_sql and t1.date_to >= t2.date_sql;
provides following output (not ordered):
For information: I changed the names of the date_from/date_to columns for a better understanding (e.g. 20-Aug-16 = date_from, 22-Aug-16 = date_to).
Regards,
Florian
Add a comment