Former police officer Daniel Hadley has had a drug charge for cocaine possession dismissed on mental health grounds.

Mr Hadley, 28, the son of popular radio broadcaster Ray Hadley, was arrested while off-duty at a hotel in Rouse Hill in Sydney's north-west in August, and charged with possessing a prohibited drug.

Appearing in Parramatta Local Court on Wednesday, he was granted a section 32 dismissal on the grounds of mental illness on the condition he continue a mental health treatment plan for the next six months.

Daniel Hadley was granted a section 32 dismissal on the grounds of mental illness.

Mr Hadley was charged after an investigation by the police professional standards command and was suspended after his arrest. He had been a senior constable but resigned from the force in September.