Personally, I don't McGuiver stuff so I couldn't tell ya. It's a shot in the dark and I would rather do it once then do it again when/if it doesn't work. Same goes for used/junk yard parts. With electrical sensors, I don't mess with junk yard ones.
That being said, thinking harder about it I think all d-series ones are the same. You have a d-series now and the new one is from a d-series correct? I would call the dealer and have them cross the part numbers to see if they work. They should be able to tell you all the vehicles that the sensor out of your 97 fits.