I would say there is something missing or incorrect in this formula $num_days Please recheck it and let us know.