The Martian · Andy Weir, 2011
How long was Mark Watney on Mars?
~549sols
About 549 sols from landing to launch, on a mission planned to last 31.
From the bookThe map's guess
Ares 3 lands on sol 1 for a 31-sol surface mission. On sol 6 a dust storm forces an abort, and the crew leave thinking Watney is dead. He stays until the Ares 4 MAV launches from Schiaparelli, which this map puts around sol 549.
Take that number as approximate. Like most sol numbers on this map it is marked ~: the order of events is from the book, the exact sols are mostly filled in.
Most of the time goes on waiting and preparing. The drive itself starts around sol 449 and takes about a hundred sols, a morning of driving and a day of recharging at a time.
See the launch