Well, I might interpret that "shortly before" as meaning a year or two. "Shortly before" in the grand sweep of Trek history. I just can't wrap my head around Kirk commanding the ship more than around 6 months before the official start of the 5YM. In TMP he says he spent "five years out there", so I interpret that to mean that he commanded a starship for five years, not seven.
Except that line is problematical because we know Kirk had been serving on starships "out there" for about 11 years before TOS began. So he had lots more than five years of experience in deep space. Also, per his behind-the-scenes biography, the Enterprise was not his first command. TMoST says his first command was a smaller, destroyer-equivalent vessel.
Maybe we can interpret his line as referring specifically to the 5-year tour of deep-space exploration, as opposed to different mission profiles closer to home, which might have made up the bulk of his prior command experience. In which case we wouldn't need to take it to refer to his entire career as a captain, just to the time he spent "out there" beyond the limits of known space.