The Spanish letter D can be pronounced in two different ways.
1. When the D is at the beginning of a word or after L or N, it is pronounced like an English D as in "dog" or "had."
2. When the D follows a vowel or any consonant except L or N, it sounds like a voiced English TH as in "this" or "bathe." At the end of a word, it may be pronounced more softly or not at all.
Please note that this explanation is only a guideline for the Spanish that I know, which is Castilian Spanish. There are many regional variations in Spanish pronunciation.