Translation:When did you say that to my friend?
It depends upon the context and sentence structure. For example, ça n'a pas d'importance = it does not matter. Whereas, when did you say it to my friend is probably best expressed as quand l'avez-vous dit à mon ami. But my French is a little rusty so, hopefully, someone like Sitesurf can verify this.
Ça translates to it only when it couldn't have been another pronoun (for instance Ça change = It changes). Here, you can easily change it to le (Quand l'avez-vous dit à mon ami ?). Basically:
- Quand avez-vous dit ça à mon ami ? = When did you say that to my friend?
- Quand l'avez-vous dit à mon ami ? = When did you say it to my friend?