Possible workday() bug/undefined behaviour

BenBl
New Member

Hey all,

I’m testing out workday() in a template. It’s Saturday, Feb 20th. Workday(today(),0) is returning Sunday, Feb 21. I’m not sure what behaviour one should get doing (Saturday, 0), but it almost definitely shouldn’t be returning a weekend day.

This isn’t mentioned in the workday() docs. What should happen?

Edit: Possibly related: now() is seemingly returning the wrong time. The docs for date and time say it should reflect the current user’s time – but as you can see in the screenshot (computer clock is bottom right), that is not the case. My timezone is set correctly to PST.

1 7 343
7 REPLIES 7

I m not perfectly sure but when we pass 0 as second argument, it seems the expression is always returning the data value passed to 1st argument regardless the 1st argument date is weekday or weekend.

On the documentation, the 2nd argument value is said to be either positive or negative value, not saying we are able to pass 0 value to it.

What do you want to acutally achieve with expression of

weekday(today(),0)

by the way.

I generate a list of all business days for 5 days including the day it’s generated on.

E.g. if I run it on Saturday, I want Monday through Friday

If I run it on Monday, I want Monday through Friday.

If I run it on Tuesday, I want Tuesday through Monday.

Not sure what you exactly want to do , but something like this?

IFS(
WEEKDAY(TODAY()=1,LIST(TODAY()+1,TODAY()+2,TODAY()+3,TODAY()+4,TODAY()+5)),
WEEKDAY(TODAY()=2,LIST(TODAY(),TODAY()+1,TODAY()+2,TODAY()+3,TODAY()+4)),
WEEKDAY(TODAY()=3,LIST(TODAY(),TODAY()+1,TODAY()+2,TODAY()+3,TODAY()+6)),
WEEKDAY(TODAY()=4,LIST(TODAY(),TODAY()+1,TODAY()+2,TODAY()+5,TODAY()+6)),
WEEKDAY(TODAY()=5,LIST(TODAY(),TODAY()+1,TODAY()+4,TODAY()+5,TODAY()+6)),
WEEKDAY(TODAY()=6,LIST(TODAY(),TODAY()+3,TODAY()+4,TODAY()+5,TODAY()+6)),
WEEKDAY(TODAY()=7,LIST(TODAY()+2,TODAY()+3,TODAY()+4,TODAY()+5,TODAY()+6))
)

@tsuji_koichi & @MultiTech_Visions , Thanks for your workarounds!

@Steve , Thanks for the suggestion. It’s now been reported.

I’m thinking the formula doesn’t know what to do with that input.

Alt version of @tsuji_koichi’s formula

Switch(WEEKDAY(TODAY()),
	1, LIST(TODAY()+1,TODAY()+2,TODAY()+3,TODAY()+4,TODAY()+5),
	2, LIST(TODAY(),TODAY()+1,TODAY()+2,TODAY()+3,TODAY()+4),
	3, LIST(TODAY(),TODAY()+1,TODAY()+2,TODAY()+3,TODAY()+6),
	4, LIST(TODAY(),TODAY()+1,TODAY()+2,TODAY()+5,TODAY()+6),
	5, LIST(TODAY(),TODAY()+1,TODAY()+4,TODAY()+5,TODAY()+6),
	6, LIST(TODAY(),TODAY()+3,TODAY()+4,TODAY()+5,TODAY()+6),
	7, LIST(TODAY()+2,TODAY()+3,TODAY()+4,TODAY()+5,TODAY()+6)
)
  • Instead of recalculating the Weekday(today()) over and over

Steve
Platinum 4
Platinum 4

Looks like a bug to me. Please report it to support@appsheet.com.

Reported. Thanks!

Top Labels in this Space