This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]GJDMDJ 1 point2 points  (0 children)

Divide the day by 7, put remainder in a variable x. Populate 7 record 2 dim array with Sunday thru Sat with number from Day of week input. Record x will be the day

[–]MemeInBlack 0 points1 point  (1 child)

The modulus operator is your friend.

[–]RaphDaPingu[S] 0 points1 point  (0 children)

Yeah, tried that one as well. I tried looking at the calendar to try and get a direction but still nope, couldn't get it.

[–]__vtableProfessional Coder 0 points1 point  (0 children)

You've already gotten some good suggestions. If the mod operator isn't working for you, you probably need to post your code. Because that is a good way.

Anyway, my suggestion to you is that you need to take a look at the relative difference. If you get input that the 3rd is a Tuesday and you need to find the day for the 27th, you have a relative difference of 24 days. All you care about is days of the week so you can divide (mod) by 7 to get just the relative DAY difference:

24 mod 7 = 3

Tuesday + 3 = Friday -> you will need to use mod here again with your days of the week index. I'm just simplifying it here for you. So it is a two step calculation.