
465 So.2d 1262 (1985)
Anthony M. KIRKMAN, Petitioner,
v.
Louie L. WAINWRIGHT, Secretary, Department of Corrections, Respondent.
No. 85-105.
District Court of Appeal of Florida, Fifth District.
February 15, 1985.
Rehearing Denied March 27, 1985.
*1263 James B. Gibson, Public Defender, and David A. Henson, Asst. Public Defender, Daytona Beach, for petitioner.
Jim Smith, Atty. Gen., Tallahassee, and Margene A. Roper, Asst. Atty. Gen., Daytona Beach, for respondent.
SHARP, Judge.
Kirkman petitions this court for a writ of habeas corpus on the grounds that he is entitled to immediate release from the Department of Corrections. We agree and issue the writ.
Petitioner was sentenced to thirty years for a robbery conviction in 1975, ten years of which were to be served in prison and twenty years on probation. He served approximately four years, and then was released on parole.
In 1984, he was found guilty of violating his probation,[1] and he was sentenced to a four and one-half year prison term. This was within the Sentencing Guidelines, Fla. R.Crim.P. 3.701, presumptive sentence range, according to his scoresheet,[2] and the court at sentencing did not state it was "departing" from the Guidelines sentence. It also credited Kirkman with ninety days for the time served after his probation violation until time of sentencing. However, the court gave him no credit for the four years served prior to his release on parole.
Kirkman filed an appeal from the trial court's denial of his motion filed pursuant to Florida Rule of Criminal Procedure 3.850, to obtain credit for that prison term and this petition for writ of habeas corpus, on the grounds that had he properly been given credit for the prior prison time served, he was entitled to be immediately released.
The state argues that the trial court intended to sentence Kirkman to a term of years which would be sufficiently long to result in a four and one-half year term, after giving him credit for the prior time served in prison. This would have required the trial court to enter a "departure" sentence under the Guidelines, which it clearly could have done. Fla.R.Crim.P. 3.701(d)(11); Hendrix v. State, 455 So.2d 449 (Fla. 5th DCA 1984) (departure based on prior record); Carter v. State, 452 So.2d 953 (Fla. 5th DCA 1984) (violation of probation sufficient basis for departure).
However, although the trial court may have intended this result, it did not sentence Kirkman in the manner to achieve that goal. Meintzer v. State, 399 So.2d 133 (Fla. 5th DCA 1981). Having sentenced him to four and one-half years, neither the trial court, nor we, can change that sentence. Harrison v. Wainwright, 408 So.2d 800 (Fla. 5th DCA), rev. denied, 419 So.2d 1201 (Fla. 1982).
It is clear that pursuant to section 921.161, Florida Statutes (1983), a criminal defendant being sentenced after the violation of his probation, is entitled to receive credit on that sentence for all prison or jail time served, including that which preceded his release on probation. Harrison; Meintzer; State v. Jones, 327 So.2d 18 (Fla. 1976).
Since that credit for prison time in this case results in Kirkman having served at least three months longer than the four and one-half year Guideline sentence imposed, *1264 we order him immediately discharged from custody. Either party may file a timely petition for rehearing, but the respondent shall immediately release the petitioner.
WRIT GRANTED; PETITIONER RELEASED FROM CUSTODY.
COBB, C.J., and FRANK D. UPCHURCH, Jr., J., concur.
NOTES
[1]  The parties have not argued that the trial court improperly revoked petitioner's probation (see Stafford v. State, 455 So.2d 385 (Fla. 1984); Thomas v. State, 434 So.2d 20 (Fla. 2d DCA 1983)), and Kirkman did not appeal from that order. In any event, the ten year parole period has also virtually expired in this case, so that point would make no material difference.
[2]  The presumptive range under the Guidelines was three and one-half to four and one-half years.
