2 Samuel 3:35

3:35 Then all the people came and encouraged David to eat food while it was still day. But David took an oath saying, “God will punish me severely if I taste bread or anything whatsoever before the sun sets!”

2 Samuel 12:16

12:16 Then David prayed to God for the child and fasted. He would even go and spend the night lying on the ground.