Skip to content

multiplyInterval - Multiply an interval by some number

The multiplyInterval function multiplies a given interval by a number. This allows for extrapolation over time.

Note

multiplyInterval works for both integer and decimal values.

Syntax

Like many functions in DataPrime, multiplyInterval supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.

multiplyInterval(i: interval, factor: number): interval
(i: interval).multiplyInterval(factor: number): interval

Arguments

NameTypeRequiredDescription
iintervaltrueThe interval to be multiplied
factornumbertrueThe factor by which this interval should be multiplied

Example - Calculating overall time remaining

Consider the following document:

{
    "jobs_in_queue": 25,
    "time_per_job_seconds": 30
}

We can see that we have 25 remaining tasks, and each task will take around 30s. In order to calculate how long the overall wait time is, we can use multiplyInterval:

create overall_wait_time from toInterval(time_per_job_seconds, 's').multiplyInterval(jobs_in_queue)
create overall_wait_time from time_per_job_seconds.toInterval('s').multiplyInterval(jobs_in_queue)

This results in the following document:

{
    "jobs_in_queue": 25,
    "time_per_job_seconds": 30,
    "overall_wait_time": 12m30s
}