---
title: "Gateway - How to compute the difference in days between the current date and a given date"
description: "Computing the difference in days between the current date and a given date uses Rule functions. The process involves converting dates to epoch, subtracting, dividing by 86400, and formatting the result as days."
url: "https://docs.itrsgroup.com/docs/faq/geneos/115004021605-geneos-gateway-how-to-compute-the-difference-in-days-between-the-current-date-and-a-given-date/index.html"
---
## Use Rules

This can be done by configuring a Rule and using its several functions.

## Use case

There may be a requirement to compute the number of remaining days from an expiry date. The [Toolkit sampler](/faq/downloads/geneos/115004021605-inline-attachment-1-sampler.xml) below is configured to extract the value of the expiry date:

![Toolkit no rule](https://docscdn.itrsgroup.com/faq/images/geneos/115004021605-inline-1-toolkit_no_rule.png)

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](https://docs.itrsgroup.com/docs/geneos/current/processing/monitoring-and-alerts/geneos_rulesactionsalerts_tr/index.html#parseDate) function.
- logic02 - Subtract the converted *expiry* value to the value of the [now()](https://docs.itrsgroup.com/docs/geneos/current/processing/monitoring-and-alerts/geneos_rulesactionsalerts_tr/index.html#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](https://www.epochconverter.com/).
- logic04 - Format the dividend in logic03 to display it as a whole number and with a "days" suffix

The resulting dataview is:

![Toolkit with rule](https://docscdn.itrsgroup.com/faq/images/geneos/115004021605-inline-2-toolkit_with_rule.png)

[Here is the rule configuration](/faq/downloads/geneos/115004021605-inline-attachment-2-rule.xml) for reference.

## Related downloads

- [sampler.xml](/faq/downloads/geneos/115004021605-6882064645149-sampler.xml)
- [rule.xml](/faq/downloads/geneos/115004021605-6882271373725-rule.xml)


