FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date. For more details, review the migration guide. Contact support@fauna.com with any questions. |
TimeSubtract
This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics. |
TimeSubtract( base, offset, unit )
time_subtract( base, offset, unit )
TimeSubtract( base, offset, unit )
TimeSubtract( base, offset, unit )
TimeSubtract( base, offset, unit )
Description
The TimeSubtract
function decreases a base
Timestamp or
Date by subtracting the offset
in units
.
Parameters
Parameter | Type | Definition and Requirements |
---|---|---|
|
Timestamp or Date |
A Timestamp or Date to subtract from. |
|
Integer or Long |
The integer number of |
|
String |
Unit of the When When
|
Returns
When base
is a Date, a new Date which represents base
with offset
unit
s subtracted from it.
When base
is a Timestamp, a new Timestamp which
represents base
with offset
unit
s subtracted from it.
Examples
The following query subtracts 1 second from 1 day after Unix epoch:
Time("1970-01-01T23:59:59Z")
FaunaTime('1970-01-01T23:59:59Z')
{0 62135683199 <nil>}
FaunaTime(1970-01-01T23:59:59Z)
Time("1970-01-01T23:59:59Z")
The following query returns a Timestamp 5 seconds in the past before now:
[ Time("2019-10-22T16:45:19.755048Z"),
Time("2019-10-22T16:45:14.755048Z") ]
[FaunaTime('2021-01-18T21:47:21.114Z'), FaunaTime('2021-01-18T21:47:16.114Z')]
[{879000000 63746603234 <nil>} {879000000 63746603229 <nil>}]
Arr(FaunaTime(2019-10-22T16:45:13.988Z), FaunaTime(2019-10-22T16:45:08.988Z))
[ Time("2021-06-23T12:24:16.798Z"), Time("2021-06-23T12:24:11.798Z") ]
The following query returns a Date 1 day before 2019-11-26:
Date("2019-11-25")
2019-11-25
{0 63710236800 <nil>}
FaunaDate(2019-11-25 12:00:00 AM)
Date("2019-11-25")
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!