Hundreds of patients across Scotland have been waiting more than a year for treatment, it has emerged.

A total of 12,275 patients have had to wait more than six months for treatment since 2016-17.

Under Treatment Time Guarantee legislation - introduced when First Minister Nicola Sturgeon was health secretary - patients requiring either inpatient or day treatment in hospital should receive it within 12 weeks.

The statistics, obtained by the Scottish Lib Dems under Freedom of Information, also shows that there are 434 people currently needing treatment who have been on the waiting list for more than a year.

The figures also show that a patient in the NHS Tayside area has been waiting 849 days for hospital treatment despite the legislation setting out a maximum waiting time of 84 days.

An NHS Tayside spokeswoman said a patient being forced to wait almost two-and-a-half years for treatment was "rare."

She said: "Such long waits are rare and can relate to many factors. These include elective treatment being postponed due to a high demand for emergency procedures; medical staff assessing individual patients as being clinically unfit for surgery; and patients advising us that they are unavailable for surgery due to personal reasons.

"In the cases where patients are deemed unfit, it may be that further clinical investigations need to be completed before the patient can have their surgery and, even during this time when patients are unavailable, they are still counted in our waiting times figures."

She added: "Our clinicians work really hard to make sure people have their planned surgery as quickly as it can be arranged as they know that any delay can be an anxious time for patients and their families."

But Scottish Liberal Democrat health spokesman Alex Cole-Hamilton, whose party uncovered the figures, said they revealed "shocking" breaches of the Treatment Time Guarantee.

Mr Cole-Hamilton said: "We knew the First Minister's 84-day Treatment Time Guarantee was being routinely breached. It is shocking to now uncover the sheer scale of these breaches.

"The number of people waiting over a year for procedures, when the law says it should take no longer than 12 weeks, is going up and up.

"This is disrupting people's lives and work, leaving them in discomfort and pain."

He continued: "Patients are still sent letters telling them of their rights under the law Nicola Sturgeon put pen to paper on. But these letters, like the law itself, are not worth a jot."

Health Secretary Jeane Freeman has put forward a plan for Scotland's NHS to meet waiting times targets by 2021 - but the Liberal Democrats said this would be a full decade after the Patient Rights (Scotland) Act, which established the 12-week guarantee, was passed.

A Scottish Government spokeswoman said: "The Health Secretary has been clear that we want to stop anyone from waiting too long for treatment, and that it is not acceptable for this to happen.

"That is why the Scottish Government recently launched its new £850 million waiting times improvement plan.

"The plan sets out action to increase capacity, increase clinical effectiveness and efficiency and design and implement new models of care.

She added: We will continue to work with boards to ensure this additional funding delivers the substantial and sustainable improvements needed."