[Solved] Work schedule

Discuss the spreadsheet application
Post Reply
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

[Solved] Work schedule

Post by RusselB »

Planning ahead for 2019; I'm trying to make a schedule so that days I won't be working are automatically filled in.
I've barely started on the project and have already run into a problem I've been unable to understand, and, therefore, unable to find a solution.
With the changes at my work, I will have Sundays, Mondays and Statutory holidays off. I created a small chart on Sheet2 for the Stat holidays.
My dates are in Column A and in Column B (for now), I want to return a 0 if the date in column A is a day I don't work, or a 1 if I do.
Everything seems to work fine for the first date of Jan 1 2019; but all of the rest of the dates (up to Feb 6, so far) return #NA

My spreadsheet is attached.

I'm looking for 1) an explanation and a solution... though an explanation alone might enable me to figure out a solution myself.
Attachments
Work 2019.ods
(14.76 KiB) Downloaded 55 times
Last edited by RusselB on Sun Nov 11, 2018 4:18 am, edited 1 time in total.
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
njhub
Posts: 33
Joined: Thu May 17, 2018 8:36 am
Location: Mayotte YT

schedule

Post by njhub »

Hello RusselB
Try with:

Code: Select all

=IF(SUM(ISERROR(MATCH($A2,Sheet2.$A$1:$A$12,0)),NOT(OR(WEEKDAY($A2,2)=7,WEEKDAY($A2,2)=1)))>1)
because weekday cant be 0, 1 for sunday, 2 for monday,... 7 for saturday
Last edited by njhub on Sat Nov 10, 2018 5:37 pm, edited 1 time in total.
LibreOffice (fr_YT): 6.1.4.2 (26/12/2018)
OS : Windows 10.0
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Work schedule

Post by Villeroy »

If the date in A is a Sunday or a Monday or is in the table on Sheet2, then return 0 in column B; otherwise return 1

Code: Select all

=(WEEKDAY(A2;1)>2)*ISNA(MATCH(A2;$Sheet2.$A$1:$A$12;0))
weekday( d ; 1) returns 1 for Sunday, 2 for Monday. MATCH returns #NA in case of no match.
We search for weekdays > 2 and non-matching dates.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: Work schedule

Post by RusselB »

Thanks to both of you.
@njhub: The WEEKDAY function can return 0, if the 2nd parameter is 3, but other than that, you are correct that the function will not return a 0

While I'm going to mark this as solved, since a couple of solutions were provided, I'm still at a loss as to why my original formula only worked for one entry.
I'd love to know why it worked for the date of Jan 1 2019, but returned #NA for any other date.
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
njhub
Posts: 33
Joined: Thu May 17, 2018 8:36 am
Location: Mayotte YT

Re: [Solved] Work schedule

Post by njhub »

RusselB-Work 2019.png
LibreOffice (fr_YT): 6.1.4.2 (26/12/2018)
OS : Windows 10.0
Post Reply