The expiry date for many tablets is about 2 to 3 years, although some is longer. The box or bottle should have the actual recommended expiry date on it. If it doesnt, then you will have to play safe and not use the Bactrim. Most medication will become less effective after it expires but some will deteriorate and the byproducts will then cause an allergy or side effect.
Because tablets are tested very thouroughly then the expiry date will be the last date at which the FDA recommend administration. After this date, there will be no evidence of safety or efficiacy tests.
As a pharmacist I cannot recommend that you take Bactrim after it has expired. Legally if you were to suffer adverse events, then you would have been to have gone outside the manufacturers recommendation.
In addition, in the UK we do not use Bactrim as a compound so often, owing to the increased risk of side effects, even within therapeutic guidance.
This website tells of a patient who suffered problems which led to changes in UK use:
The information regarding metabolites etc on deterioration is not freely available and requires access to a School of Pharmacy Library or subscription to the British Pharmacopia, which I do not currently have access to.
Your intial question is Bactrim safe.... My answer is no. In addition, although you had the Bactrim prescribed two years ago, you do not know how old it was when it was issued. If the pharmacist thought you were taking it straight away then it could actually have expired a month after being given it.
At the very least, if you take it now it will not be as effective and could predispose you to increased risk of resistance as bacteria which are exposed to subtherapeutic doses can develop resistance, making them harder to treat next time.
To get the answer of which metabolites are present on degradation, you will need access to scientific literature that I have not been able to get into.