I just wrote a piece of code to return the time of the beginning of the shift and this line is giving me problems:
GetDate(GetYear(now()), GetMonth(now()), GetDayofMonth(now())-1)
If I just leave this:
GetDate(GetYear(now()), GetMonth(now()), GetDayofMonth(now()))
it works, but I need the day to be current date minus 1. Why is this not possible? How do I go around doing this?
This is the full code (but only that line is the problem):
Switch(
if(getHour24(now()) >= 8 && getHour24(now()) < 20, 1, 2),
1,2,
addHours(GetDate(GetYear(now()), GetMonth(now()), GetDayofMonth(now())), 8),
Switch(
if(getHour24(now()) >= 20, 3, 4),
3, 4,
addHours(GetDate(GetYear(now()), GetMonth(now()), GetDayofMonth(now())), 20),
addHours(GetDate(GetYear(now()), GetMonth(now()), GetDayofMonth(now())-1), 20),
GetDate(GetYear(now()), GetMonth(now()), GetDayofMonth(now()))),
GetDate(GetYear(now()), GetMonth(now()), GetDayofMonth(now())))
Basically it checks which shift is it and returns the time of the beginning of the shiift. The second switch checks if it passed midnight and if it did, it should return current date-1 (so previous day plus 20 hours since the shift started at 20:00)
Thanks