This is an appeal from a Pinal County Superior Court order summarily denying appellant’s petition for a writ of habeas corpus. The petition filed below claimed that the appellee was illegally detaining the appellant and requested discharge from custody. The application for relief was made December 22, 1966, and the denial was entered January 3, 1967. The claim of illegal detention was predicated upon the alleged failure of the appellee to give the petitioner the statutory credits provided for in A.R.S. §§ 31-251 and 252. We find, however, that the trial court did not err in its summary *30denial of relief since the appellant’s claim of illegal detention was refuted by the very allegations of his petition, i. e., that his release date should be February 6, 1967. His detention, therefore, was admittedly lawful.
Since this purported release date has passed, dictates of justice render appropriate consideration of appellant’s claim of illegal restraint. His complaint is directed to the administrative application of the good conduct credits provided for in A.R.S. § 31-251, 10 A.R.S.:
“A. The superintendent of the state prison shall require of each able-bodied prisoner as many hours of labor each day during his term of imprisonment as prescribed by the rules of the prison.
“B. Every prisoner faithfully performing such labor and conforming in all respects to the rules, or if unable to work, but complying in all respects to the rules, shall be allowed, if a first offender, from the minimum term of his sentence, or, if a second offender or more, from the maximum term of his sentence, a deduction of two months in each of the first two years, four months in each of the next two years, and five months in each of the remaining years of the term.”
The appellant was sentenced to a term of imprisonment of not less than 4 years and 6 months nor more than 5 years, commencing April 22, 1965. We agree with his statement that the statutory deduction for good behavior is a matter of right. Montgomery v. Eyman, 96 Ariz. 55, 391 P.2d 915 (1964); Von Hecht v. Eyman, 1 Ariz.App. 594, 405 P.2d 904 (1965); Watson v. Industrial Commission, 100 Ariz. 327, 414 P.2d 144 (1966). The appellant interprets A.R.S. § 31-251, subsec. B to mean that he is entitled to receive a deduction of seventeen months for good conduct since his maximum sentence is five years1 He seeks advance credits of thirteen months’ good behavior time when he in fact has only completed a little more than two years’ calendar time.
We have previously considered like contentions and held that good conduct credit is to be allowed at the end of each year as it is earned, and'not at the beginning of a sentence. Von Hecht v. Eyman, supra; Fragosa v. Eyman, 3 Ariz.App. 308, 414 P.2d 157 (1966). Having completed only two full years’ straight time, the appellant is entitled to no more than 4 months’ credit for good conduct and not 17 months, as he urges. His contention as to deprivation of statutory time is without merit.
Finding no error in the denial of habeas corpus relief to the appellant, the trial court’s order is affirmed.
HATHAWAY, C. J., and MOLLOY, J., concur.. He admits that he is a second offender and therefore the statutory credits are deductible from the maximum term only.