"Have you told him that" or "Did you tell him that"

Hi there !

I’m very confused about the two sentences. I’m sure that we can say both but i can’t say when and why. Can someone help me for this please ?

If you are talking about a specific past occasion, use “Did you tell him that?”.

If you are asking about any time in the past, use “Have you told him that?”. Some people also use “Did you tell him that?” in this case.

Thank you for the answer !

I agree with Dozy.

I think “Did you tell him that” is asking a specific yes/no question - asking if you did, in fact, tell him at a certain point. You could clarify the sentence by asking, “Did you tell him that on Tuesday/this morning/before you left the house?”

“Have you told him that” has a less specific timeframe - “Have you told him that yet/at any point/when you’re together?”

when you are talking about an specific time you have to use simle past but when you are talking about an action regardless of time" present perfect"