Following is the funcation can calculate the duration, actually number of days between the given parameters (from,to). The argument must be subclass of…