How long does it take for a genetic trait to dissipate if its no longer selected for?
There is no way to answer this question as there are way too many factors influencing this time.

It depends on too many factors

It depends on:


whether it is neutrally or negatively selected (and how strongly so)
the population size
mutation rate
mutational variance
level of genetic variance for this trait to start with.


This variance can be calculated at equilibrium (assuming no important demographic change "recently") from the above parameters though.



It may take between 1 generation and a billion generations.

For example

Consider for example that your trait is neutral. Assume that the trait can only take two binary state A and B and that only a single locus affect this trait, which two states are also named A and B for simplicity. Let's say A is the ancestral state and we want to know how much time it takes to have a population of B. Imagine the haploid population size is $N=10^5$. The mutation rate for the locus of interest is $\mu=10^{-9}$.

Slow Case

If at the start there are no alleles B, then you have to wait for a mutation to occur. The time for such a mutation to occur follows an exponential distribution with parameter $\mu=10^{-9}$. Because we assumed neutrality, the probability of fixation (fixation is the state when the whole population carry the same allele) is $\frac{1}{N}=10^{-5}$. Conditioning on fixation, the expected time for fixation to occur is $-4N \left(\frac{1-p_0}{p_0}\right)\ln(1-p_0)=399998$ generations. In consequence, the expected time to fixation in this case is $10^{5}*10^{9}+399998 ≈ 10^{14}$ generations, that is about 77 times the age of the earth assuming there is one generation per day! So Obviously, the environment has time to change again. Note that variance is about $10^{28}$ generations! Of course this example is just an extreme slow case, but I have been using realistic parameter values.

Fast Case

If you have a population size of $N=50$ and the B allele is already present at frequency 0.1 and that the B allele is beneficial with a selection coefficient of 1.5, then it might take about 100 generations.