Skip to content

addTime - Adds an interval to a timestamp

This function adds an interval to a timestamp value. Both timestamp and interval are first class types in DataPrime, meaning it's important to ensure that when you're using this function, the correct data types are being passed in.

Note

The addTime function also works with negative interval values, which is the same as subtracting a value.

Syntax

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

addTime(t: timestamp, i: interval): timestamp
t: timestamp.addTime(i: interval): interval

Arguments

NameTypeRequiredDescription
ttimestamptrueThe timestamp to modify
iintervaltrueThe interval, determining how much to modify the timestamp

Example - Computing end timestamp

In this example, the start_timestamp field is used, which is an existing timestamp field on the log. A duration field exists on the logs, which represents how long some process took in seconds. This duration field is parsed into an interval and then the addTime function is used to compute the time when this particular event ended.

create end_timestamp from addTime(start_timestamp, duration.toInterval('s'))
create end_timestamp from start_timestamp.addTime(duration.toInterval('s'))