Hello, using apex 4.2.1
can anyone help me please?
Why don't you want to use the out-of-box functionality? This can be configured to limited to yesterday & today.
You may also be interested in something like this