1 Samuel 21:4 But the priest answered David, “I don’t have any ordinary bread on hand; however, there is some consecrated bread here – provided the men have kept themselves from women.”
Leviticus 15:16 When a man has an emission of semen, he must bathe his whole body with water, and he will be unclean till evening.
In other words, if a man ejaculated Saturday night, he could not enter the temple that Sunday.
Leviticus 20:18 If a man lies with a woman during her monthly period and has sexual relations with her, he has exposed the source of her flow, and she has also uncovered it. Both of them must be cut off from their people.
Obviously, this created a regular abstinence from sex.
2 Samuel 11 11 Uriah said to David, “The ark and Israel and Judah are staying in tents, and my master Joab and my lord’s men are camped in the open fields. How could I go to my house to eat and drink and lie with my wife? As surely as you live, I will not do such a thing!”