×
Back to Geneos FAQ
Gateway - How to compute the difference in days between the current date and a given date
Use Rules Copied
This can be done by configuring a Rule and using its several functions.
Use case Copied
There may be a requirement to compute the number of remaining days from an expiry date. The Toolkit sampler below is configured to extract the value of the expiry date:
To compute and display the remainingDays value, the rule must be configured with the following targets and logic:
- rule target - remainingDays column
- path alias target - expiry column
- logic01 - Convert the expiry column value to epoch using the rule’s parseDate function.
- logic02 - Subtract the converted expiry value to the value of the now() function. The now() function extracts the current timestamp in epoch format.
- logic03 - Divide the difference in logic02 by 86400. 86400 is the epoch format of 1 day.
- logic04 - Format the dividend in logic03 to display it as a whole number and with a “days” suffix
The resulting dataview is:
Here is the rule configuration for reference.
Related downloads Copied
["Geneos"]
["Geneos > Gateway"]
["FAQ"]