Step 1: Choose the two distinct digits.
The available digits are
\[
1,2,3,4,5,6,7,8,9
\]
There are \(9\) digits.
We need exactly \(2\) distinct digits in each four digit number.
Number of ways to choose \(2\) digits from \(9\) digits is
\[
{}^9C_2
\]
So,
\[
{}^9C_2=\frac{9\times 8}{2}=36
\]
Step 2: Arrange the selected two digits in four places.
Suppose the two selected digits are \(a\) and \(b\).
Each of the four places can be filled by either \(a\) or \(b\).
So total arrangements are
\[
2^4=16
\]
But we need exactly \(2\) distinct digits.
So the numbers having only \(a\) or only \(b\) must be excluded.
These two invalid cases are
\[
aaaa
\]
and
\[
bbbb
\]
Hence, valid arrangements for each pair are
\[
2^4-2=16-2=14
\]
Step 3: Calculate total number of four digit numbers.
Total required numbers are
\[
{}^9C_2(2^4-2)
\]
Substituting the values,
\[
36\times 14=504
\]
Step 4: Final conclusion.
Therefore, the number of four digit numbers is
\[
\boxed{504}
\]