Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi, i have this code in script during the weekdays (Mon-Fri) 3 shifts
But on saturday and sunday we only have 2 shift.
Can i manipulate this in a way?
Weekdays (Mon-Fri) 3 shift
if(time(frac(ScheduledAt))>=('06:00:00') and time(frac(ScheduledAt))<=('13:59:59'),'Day',
if(time(frac(ScheduledAt))>=('14:00:00') and time(frac(ScheduledAt))<=('21:59:59'),'Evning','Night')) as WoShift
Saturday we only have 2 shifts
06:00 to 17:59 and 18:00 to 05:59
Is there possibility to get in the same in above?
More simpler and clearer:
MAP_WORKDAYS:
Mapping
load
Hour,
if(Hour>=6 and Hour<14,'Day',if(Hour>=14 and Hour<22,'Evening','Night')) as Shift;
load
RecNo()-1 as Hour
AutoGenerate 24;
MAP_WEEKEND:
Mapping
load
Hour,
if(Hour>=6 and Hour<18,'Day','Night') as Shift;
load
RecNo()-1 as Hour
AutoGenerate 24;
T:
load
*,
if(WeekDay(ScheduledAt)<5,ApplyMap('MAP_WORKDAYS',Hour(ScheduledAt)),ApplyMap('MAP_WEEKEND',Hour(ScheduledAt))) as Shift
From ...
Hi @John-SSI,
Try using the Weekday()-Function, it returns a value from 0 to 6, 0 being monday.
So you could create additional cases for saturday and sunday via if-statements, depending on weekday(ScheduledAt).
Hope this helps!
More simpler and clearer:
MAP_WORKDAYS:
Mapping
load
Hour,
if(Hour>=6 and Hour<14,'Day',if(Hour>=14 and Hour<22,'Evening','Night')) as Shift;
load
RecNo()-1 as Hour
AutoGenerate 24;
MAP_WEEKEND:
Mapping
load
Hour,
if(Hour>=6 and Hour<18,'Day','Night') as Shift;
load
RecNo()-1 as Hour
AutoGenerate 24;
T:
load
*,
if(WeekDay(ScheduledAt)<5,ApplyMap('MAP_WORKDAYS',Hour(ScheduledAt)),ApplyMap('MAP_WEEKEND',Hour(ScheduledAt))) as Shift
From ...
Works like a charm 🙂