When to use which date function in RapidPro
July 6, 2016
As you may know there are many variables you can use in RapidPro to save or refer to date and time values. This post will look at the most common date variables and how to use them.
If you want to refer to the date today only, you can use either @date.today or @(today()). In an outgoing message (sent on 05-07-2016) these variables will appear as follows:
Note that the date format is dependent on the date format settings in your account (under Account Settings). In our case the format is set as dd-mm-yyyy.
Date today and current time
In some cases you may want to refer to both the current date and time. To do this you can use either @date, @date.now or @(now()). These variables will look like this in a message (which is sent at the shown date & time):
Saving Date & Time
Besides displaying the date in an outgoing message, it is also possible to save date and time in RapidPro. For example, if you want to save the date and time as a contact field you can use the Update Contact ActionSet. In the action box below we save the current date and time (referenced as @date.now) in the contact field Registration Date.
Make sure that any contact field containing date (and time) is set as Date & Time. If the format is not set right, referencing this field in the future may not work properly.
To set the format for contact fields, you can go to Contacts and choose “Manage Contact Fields”.
Other date variables
There are many other variables and functions for date and time you could use in RapidPro depending on your use case. You could reference a date in the future or past, add/subtract days from dates, deduct number of days between two dates, etc. You can check the RapidPro knowledge base for more information on how to use these variables.