Please become accustomed to provide decent context info of your problem.
It is always helpful to support a request with system info like OS and shell, related environment (variables, options), preferred tools, adequate (representative) sample input and desired output data and the logics connecting the two, and, if existent, system (error) messages verbatim, to avoid ambiguities and keep people from guessing.
I have extreme difficulties to understand what you're doing / trying up there. You seem to
mix up shell and awk syntax
use the dm variable before it is defined
not pass the variable correctly into the awk script.
Why do you use FOUR commands when the entire logics can be covered in one single only?
Where is the `( substr($11,2,8) -lt $dm )` construct (shell command substitution in its deprecated form) used?