date difference function is working correctly