Two days at the most. If you let it go to long, it will become impacted and then only a hospital can relieve the pain. The doctor might suggest a enema or laxitive. Call your doctor first before you take him to the hospital. A two year old can't explain the pain but he sure can scream in pain.
Everybody has different bowel habits and that includes children. Usually if three days pass without a bowel movement, an enema or suppository should be given. Waiting much longer can cause a bowel impaction.