A defendant, confined during the pendency of an unsuccessful review or appeal, or convicted at a new trial ordered by the appellate court, shall have the period of the defendant's former confinement deducted from the period of confinement fixed on the last verdict of conviction by the district court.
Iowa Code § 814.27