The discrete effect on the boundary condition has been a fundamental topic for the lattice Boltzmann method in simulating heat and mass transfer problems. In previous works based on the halfway anti-bounce-back (ABB) boundary condition for convection-diffusion equations (CDEs), it is reported that the discrete effect cannot be commonly removed in the Bhatnagar-Gross-Krook (BGK) model except for a special value of relaxation time. Targeting this point in the present paper, we still proceed within the framework of BGK model for two-dimensional CDEs, and analyze the discrete effect on a non-halfway ABB boundary condition which incorporates the effect of the distance ratio. By analyzing an unidirectional diffusion problem with a parabolic distribution, the theoretical derivations with three different discrete velocity models show that the numerical slip is a combined function of the relaxation time and the distance ratio. Different from previous works, we definitely find that the relaxation time can be freely adjusted by the distance ratio in a proper range to eliminate the numerical slip. Some numerical simulations are carried out to validate the theoretical derivations, and the numerical results for the cases of straight and curved boundaries confirm our theoretical analysis. Finally, it should be noted that the present analysis can be extended from the BGK model to other lattice Boltzmann (LB) collision models for CDEs, which can broaden the parameter range of the relaxation time to approach 0.5.