How far back can code enforcement go on unpermitted construction?

A tip comes in on a detached garage with living space above it, built sometime around 2009, no permit on file. The owner's lawyer calls before your inspector even gets out there and asks the question every zoning administrator eventually hears: isn't there a statute of limitations on this?
Usually, no. Not in the way the question assumes.
Unpermitted structures are a continuing violation, not a one-time act
Most states treat an unpermitted structure as an ongoing violation of the zoning or building code, not a single event that happened and ended the day the walls went up. A statute of limitations runs from when a violation occurs. If the violation is "this structure exists without a permit," it occurs every day the structure stands. There's no date in the past for the clock to start from, because the clock resets daily.
This is different from a construction-defect claim, where a state might give a property owner six or ten years to sue a builder over a leaking roof. That repose period protects contractors from open-ended liability for workmanship. It has nothing to do with a municipality's police-power authority to require a permit before a structure exists. Confusing the two is the most common thing a property owner's attorney will try, and it's usually wrong.
Some states do put a limit on criminal prosecution of a code violation, often a few years, treating it like a misdemeanor charge with its own statute of limitations. That limit applies to fines and criminal penalties, not to a civil abatement order compelling the owner to get a permit, bring the structure up to code, or remove it. A jurisdiction that's past the window to prosecute can usually still order the work resolved.
Where vested rights and laches actually bite
The defense that sometimes works isn't a statute of limitations. It's vested rights or laches, and both require the owner to show something more than "it's been a while."
Vested rights typically requires the owner to show the municipality took some affirmative act that led them to believe the use was lawful: issuing a certificate of occupancy that covered the addition, approving a building permit that should have caught the discrepancy, or something similar on the record. A neighbor not calling it in for fifteen years isn't an affirmative act. Neither is the structure sitting there unnoticed.
Laches is closer to the "how far back" instinct, but it's a harder defense to win against a government zoning action than most owners expect. Courts generally require proof of two things: unreasonable delay by the jurisdiction, and real prejudice to the owner from that delay, not just the passage of time. An owner has to show the city knew, or should have known, and sat on it anyway, and that the delay caused specific harm, like the owner buying the property in reliance on the structure's apparent legality or making improvements that would've been avoided with earlier notice.
That's where these cases get decided one at a time, and it's also where a department's own records become the deciding factor.
Proof of date matters more than the clock does
If a vested rights or laches argument comes down to what the jurisdiction knew and when, the department needs a record that shows exactly that: when a structure first appeared, and whether it ever matched anything in the permit file. A handwritten note in a parcel folder from a 2011 drive-by doesn't hold up the same way a dated image does. An assessor's card that's never been updated doesn't tell you when the addition went in, only that nobody noticed.
This is the real argument for comparing the whole built environment against the permit register every quarter: it builds a time-stamped record, tied to parcel, that shows when a structure first showed up unpermitted and that it's been flagged consistently since. That record is what answers an owner's "you knew about this for years and did nothing" claim, because it shows exactly when the department found it and what happened after.
The "how far back" question almost always resolves the same way: there's no limitations clock protecting an unpermitted structure, but there is a real defense available to an owner who can show the jurisdiction had notice and sat on it. The department that keeps a dated, parcel-level record of what it found and when closes that door before an attorney ever gets to open it.
If your department is working off complaint logs and old inspection notes to answer that question, it's worth seeing what a dated flagged list looks like for your jurisdiction.