The maximum length of time that a beer should be left in secondary will vary by style and with personal preference of the brewer. However, we generally do not recommend leaving your beer in the secondary for more than a few months if you are bottling it.
If bottling after more than 4 weeks of secondary, you'll likely benefit from adding a small amount of yeast to your bottling bucket (roughly ¼ - ½ of a yeast packet will suffice). If yeast are not added, your beer may take an extended period of time to fully carbonate, if at all. Be aware that some styles of beer may be in carboy for up to a year for proper taste and will therefore require additional yeast when bottling.