You shouldn't keep the food in the oven for longer than a couple hours because you risk overcooking the food.
However to keep food warm in the oven for at least 2 hours you should cover the food in tin foil and then place the food in the oven on 200 F which will be just enough warmth to keep the food from becoming cold.
The food should be removed from the oven within 2 hours and served to prevent the food from drying out and becoming burnt.