Dear student,
When phase difference i.e, phi is given then we use second formula as in this formula the value of slit width is not required,we can directly generate the value of path difference. But when we are not having information about phase difference, then we use first formula i.e, yd/D. Regards