It is 533 miles according to Google Maps.
It is 1,218 miles according to Google Maps.
Depending on which way that you travel, Yosemite is about 4 hours from Sacramento. This time of the year I suggest that you use the lowest elevation route through Mariposa using CA 140.
2,690.01 kilometres (1,671.5 miles)