I don't know. This would probably require testing, which I may have time to do later. The Bulbapedia entry implies that the attacking damage (The part of the damage formula that involves your Pokemon) is calculated when the move is used, and the defensive damage (The part that involves your opponent.) is calculated when it hits. I will be testing this sometime soon.