'How to compare dates in Gitlab Pipeline?

I'm trying to create a scheduled pipeline which will run every 4 AM but the problem is that I want to run the job only if there is any commits in the previous day. I know I can get the current date and the last commit date by $CI_JOB_STARTED_AT and $CI_COMMIT_TIMESTAMP but I don't know how will compare these two. For example if the last commit date is 2022-01-26 and the current date is 2022-01-27 that means the job should run but how. I've tried comparing them by converting them to strings by "==" that works but I don't need to know if they are equal I need to know that the current date is 1 day ahead of last commit. I've pasted some of my yml script to get an idea of what I'm trying to achieve. Any help will be highly appreciated.

  stage: deploy
  script:
    - $debug_version = $xmlserver_version + "." + $CI_PIPELINE_ID
    - .\CI\DeployToDev "UK1-OFF-DEXM-02" $debug_version
  needs:
    - Publish_Debug
  dependencies:
    - Publish_Debug 
  rules:
     - if: '$CURRENT_DATE == $COMMIT_DATE'
       when: always
  when: manual
  tags: *tags
  variables:
    CURRENT_DATE: ${CI_JOB_STARTED_AT%T*}
    COMMIT_DATE: ${CI_COMMIT_TIMESTAMP%T*}```



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source