The only mention of Stargazer
in "Relics" is that it was the first ship that Picard served on as captain. Doesn't say how long he served as captain or when he became captain.
In fact, after a quick search at chakoteya.net, I can't find anything that says "served as captain of Stargazer
for twenty-two years". Memory Alpha makes the claim, citing "The Battle" and "Tapestry" as sources, but the transcripts of those episodes don't indicate any length of service as captain, either.