I already gave you the formula for what you initially wanted.
Now you're asking for external code, it's unrelated to the original topic and you should start an additional post.
And you changed what you're using, the original post stated a date range, now you speak of two different parameters.
Please be spcific with your questions, and post meaningful technical information such as the software being used, not just which version of Crystal, but your development language/version. Why would a developer think that programming languages and the Crystal API used have nothing to do with the solution?
-k