how do I convert the working hours 08:00:00-11:59:00;13:00:00-16:59:00; into 48 digit Boolean format like
"000000000000000011111111001111111100000000000000"
where each digit refers to 30 min granularity using Oracle SQL Query?
how do I convert the working hours 08:00:00-11:59:00;13:00:00-16:59:00; into 48 digit Boolean format like
"000000000000000011111111001111111100000000000000"
where each digit refers to 30 min granularity using Oracle SQL Query?
Copyright © 2021 Jogjafile Inc.
Assuming you are starting from a string which always has semicolon-separated pairs of from/to times, with a trailing semicolon after the last pair; and those times are always HH24:MI:SS with the seconds always zero as shown; then... you can split the string into multiple string pairs representing each from/to pair:
And you can generate all the half-hour blocks in a nominal day (picking one not subject to a DST switch):
And then join those together to see where there is an overlap, using string comparison (which is why the time format matters); using CTEs to provide the initial string for simplicity and then the results of the two previous queries:
And then finally aggregate those together into a single result string:
db<>fiddle
If your initial string is actually coming from a table and you need this conversion for multiple rows at once then the connect-by split is a bit more complicated, and a recursive CTE might be more suitable for that part.
Just for fun, here's an example.