At least two days, three would be better. One thing to remember about Yellowstone, is you won't be going any where very fast. You have to get through the gate each day. Roads will be congested, time you park and walk around, to see stuff, it all burns time. The actual distance between stuff is not that far, on the map. But the actual time to get anywhere and do any thing is quite a bit longer.
Grand Canyon, unless you are going to ride the train, or do some hiking is more of a one day thing. And it tends to be over run with tour buses, not something I enjoy being around. Just talking about the south rim, not the north rim or the sky bridge etc, which of course would take longer