The long answer is that it depends on the test.
You can check igg, iga, or IgM antibodies for h pylori. Some specify short term recent infection, others long. Most doctors usually don't check all three, which is appropriate. Bottom line, duration usually doesn't matter.