Look at the code again. You would detect a change of day by comparing the current value of the day with the previous value of the day. When they are different then a new day has started and you check whether the new value matches the required day number and if so you run whatever code you require.
Next time you check for a change of day it won't have happened so you do nothing. This way you only act when the day becomes the value that you are looking for rather than when it is the value that you are looking for