Hi. I want to change the following scrip to delugue
The code does this:
I have an application where entry and exit times are recorded. I want to calculate which hours are daytime and which are nighttime, with nighttime hours being from 9 PM to 6 AM.
For example if I have start time 6pm and end time 10pm wil be 3 hours day time 1 night time
Periods can cross midnight
Daily hours
Let(
[
a = Max(Time(06:00:00); Hora_Inicio);
b = Min(Time(21:00:0); If(Hora_Fin < Hora_Inicio; Hora_Fin + 86400; Hora_Fin));
];
Max(0; b - a)
)
Night hours
Let(
[
a = Max(Time(21; 0; 0); Hora de inicio);
b = Min(Time(6; 0; 0)+ 86400; If(Hora de fin < Hora de inicio; Hora de fin + 86400; Hora de fin))