How do I compare two dates?

I’m currently building an application that allows a user to review their loan, select a payment method and make a payment.

One of the requirements is to allow Debit payments to be processed in the near future (up to 7 days).

In order to do this, the user selects a payment date and then “schedules” their payment. A timer is set for the payment date, and the action chain is executed on the scheduled day.

On the Airkit side, how do I compare the scheduled date against today’s date and then use the scheduled date as the value for the timer?

1 Like

Hey @grakozy!

This is how I would tackle this:

  1. If you are using the Date Picker Control there is a property called Maximum Days Out which will determine the max number of days using today’s date as a starting point. So if you only wanted the user to pick a date up to 7 days, I would set this to 7. By doing this, is does all your validation for you.

  1. Once you’ve captured the date from the user, you want to set the timer. Let’s say i captured the date to a variable called date_input. This comes back to me as a date object that looks like this:
{  
 "day": 8  
 "month": 7  
 "year": 2022  
} 

This is only a date object, but the timer you will be using needs to be a dateTime object. So here you would use the DATETIME() function and create a dateTime object to pass to the timer. So if you wanted the timer to start at 12pm PT, the function would look like this:

DATETIME(
  date_input,
  {
    "hour": 12,
    "minute": 0,
    "second": 0,
    "millisecond": 0
  },
  "America/Los_Angeles"
)