You can definitely do it as a day trip from Porto, but it will be a pretty long day. Taking the train from Sao Bento station to Pinhao is the easiest and most beautiful way. The train ride itself is very scenic as it runs right next to the river for the last hour. Once you get to Pinhao, you can easily walk to a few local quintas for wine tastings, look at the famous blue tiles at the station, or take a short traditional rabelo boat cruise. If you want to plan it smoothly without a car, check out this practical
guidekin.com/journal/douro-valley-guide/ for tips on train schedules, best viewpoints, and winery bookings. An overnight stay is better if you want a relaxed dinner overlooking the hills, but for just seeing the landscapes and tasting wine, a day trip by train works perfectly fine.