TimeSubtract

Not available in this language yet.
Not available in this language yet.
TimeSubtract( base, offset, unit )
TimeSubtract( base, offset, unit )
Not available in this language yet.
Not available in this language yet.
TimeSubtract( base, offset, unit )
Not available in this language yet.

Description

The TimeSubtract function constructs a new Timestamp, starting from the base timestamp and subtracting the offset in units.

Parameters

Argument Type Definition and Requirements

base

A timestamp to subtract from.

offset

The number of units to subtract from the base timestamp.

unit

The offset's unit, one of:

  • day, or days

  • half day, or half days

  • hour, or hours

  • minute, or minutes

  • second, or seconds

  • millisecond, or milliseconds

  • microsecond, or microseconds

  • nanosecond, or nanoseconds

Returns

A Timestamp which represents base timestamp with offset units subtracted from it.

Examples

The following query subtracts 1 second from 1 day after Unix epoch:

Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
System.out.println(
    client.query(
        TimeSubtract(Epoch(1, "day"), 1, "second")
    ).get());
client.query(
  q.TimeSubtract(q.Epoch(1, 'day'), 1, 'second')
)
.then(ret => console.log(ret))
Not available in this language yet.
Not available in this language yet.
println(Await.result(
  client.query(
    TimeSubtract(Epoch(1, "day"), 1, "second")
  ),
  5.seconds
))
Not available in this language yet.
1970-01-01T23:59:59Z
Time("1970-01-01T23:59:59Z")
1970-01-01T23:59:59Z

The following query returns a Timestamp 5 seconds in the past before now:

Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
System.out.println(
    client.query(
        Arr(
            Now(),
            TimeSubtract(Now(), 5, Value("seconds"))
        )
    ).get());
client.query([
  q.Now(),
  q.TimeSubtract(q.Now(), 5, 'seconds')
])
.then(ret => console.log(ret))
Not available in this language yet.
Not available in this language yet.
println(Await.result(
  client.query(
    Arr(
      Now(),
      TimeSubtract(Now(), 5, "seconds")
    )
  ),
  5.seconds
))
Not available in this language yet.
[2019-10-22T16:45:19.223863Z, 2019-10-22T16:45:14.223863Z]
[ Time("2019-10-22T16:45:19.755048Z"),
  Time("2019-10-22T16:45:14.755048Z") ]
[2019-10-22T16:45:19.223863Z, 2019-10-22T16:45:14.223863Z]

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!