Since losing my virginity the longest i have been without sex would be about 18 months. I find though after a while you miss it less and less.
Longest without masturbation would be a couple of weeks. This was hard work but the orgasm was worth the wait.
Having said that though i have made a effort to reduce masturbation, i find it makes sex much more heated as my desire for it is huge.