
358 So.2d 891 (1978)
Leroy M. HALL, Appellant,
v.
STATE of Florida, Appellee.
No. 77-1616.
District Court of Appeal of Florida, Second District.
May 17, 1978.
Jack O. Johnson, Public Defender, Paul C. Helm, Asst. Public Defender, and Carole Ann Grayson, Legal Intern, Bartow, for appellant.
Robert L. Shevin, Atty. Gen., Tallahassee, and William I. Munsey, Jr., Asst. Atty. Gen., Tampa, for appellee.
PER CURIAM.
On this appeal Leroy Hall seeks credit for the time he spent in the state hospital at Chattahoochee under commitment as a mentally disordered sex offender. We hold he is entitled thereto and remand for correction of his sentence.
Appellant was originally charged with first degree murder. On May 7, 1973, pursuant to a plea bargain, he pled guilty to the lesser-included offense of second degree murder. Under the plea bargain, he was to be committed to the state hospital as a mentally disordered sex offender.
Appellant was committed to the state hospital, but was subsequently returned and brought before the court for sentencing on August 16, 1977. At sentencing the trial court refused to give him credit for the time he spent in the state hospital.
Section 917.218, Florida Statutes (1977) (Chapter 77-312, Section 24, Laws of Florida), which became effective July 1, 1977, provides:
All time spent in the formal custody of the state and in admission procedure by an offender in the mentally disordered sex offender program shall be considered credit for time served for any sentence imposed on the sex offense or attempted sex offense committed prior to the date the offender was convicted.
Because this statute was in effect at the time of appellant's sentencing, appellant is entitled to the benefit of it. See Hamilton v. State, 306 So.2d 600 (Fla.2d DCA 1975).
We find appellant's other point to be without merit. Accordingly, the judgment is affirmed, but the cause is remanded with directions to give appellant credit for the time he spent in the mentally disordered sex offender program.
BOARDMAN, C.J., and HOBSON and SCHEB, JJ., concur.
