MetaServer > Help > Extract > Calculate Time Span

120-520 MetaServer Edit – Calculate Time Span

With MetaServer’s Calculate Time Span rule, you can calculate the time between 2 dates. If you also include a time element, you can calculate the time span with a precision to the second. The result can be expressed in days or hours, minutes and seconds or combined.

It’s most frequently used for calculating payment terms on invoices or to calculate the performance of a MetaServer process. For example, to calculate the time that is needed to extract values from a document. This can be found by calculating the difference between the moment before extraction and the moment after extraction.

In our example, we will make use of the “CB – INVOICES US” workflow. This workflow is automatically installed with CaptureBites MetaServer.

Calculate Time Span rules are defined in a MetaServer Extract or Separate Document / Process Page action.

To add this rule, press the Add button and select Edit -> Calculate -> Time Span

After extracting and formatting the Due Date and invoice date, we want to determine the payment term, which is the period between the invoice date and due date in days. We can calculate this using a Calculate Time Span rule.

First, add a description to your rule. Then, select the Target field that will hold the calculated time span value. In this case, we select the field “Payment Term”.

01 – Target Field Format: enter the desired format for the calculated time span. You can press the drop-down arrow to select different format types:

d: time span specified in days
d.hh:mm:ss: time span specified in days, hours, minutes and seconds
hh:mm:ss: time span specified in hours, minutes and seconds

In our case, we want the payment term to be specified in days, so we select the “d” format.

02 – First Date: select a field that holds the first date of the time span you want to calculate. In this case, we select the field “Due Date”. 

The First Date will be subtracted from the Second Date. Consequently, the First Date should be more recent than the Second Date, otherwise the time span will have a negative value.

03 – Second Date: select a field that holds the second date of the time span you want to calculate. In this case, we select the field “Date”.

NOTE: the first and second date need to be in the same format. Otherwise, the calculation won’t work.

04 – Format: enter the current format of both selected dates. You can press the drop-down arrow to select different format types to compose your date format. In our case, both dates are formatted as MM/DD/YYYY.

TIP: you can copy the current settings and paste it in another setup window of the same type. Do this by pressing the Settings button in the bottom left of the Setup window and by selecting Copy. Then open another setup window of the same type and select Paste.


  • Extracting and formatting the invoice and due date
  • Calculating the Payment Term with the Calculate Time Span rule

we get the following result:

Result in “d” format (days)

Result in “d.hh:mm:ss” format (days, hours, minutes and seconds)

Result in “hh:mm:ss” format (hours, minutes and seconds)

Subscribe to our Newsletter

Please enable JavaScript in your browser to complete this form.

Please check the box below to agree to the privacy policy and continue *

NOTE: if you're experiencing trouble with submitting this form, please try again using another browser.