TimeDiff
Not available in this language yet.
Not available in this language yet.
TimeDiff( start, finish, unit )
TimeDiff( start, finish, unit )
Not available in this language yet.
Not available in this language yet.
TimeDiff( start, finish, unit )
Not available in this language yet.
Description
The TimeDiff
function returns the time difference between start
and
finish
, expressed in unit
units. The difference includes start
but
excludes finish
.
Parameters
Argument | Type | Definition and Requirements |
---|---|---|
|
The starting date or timestamp. |
|
|
The ending date or timestamp. |
|
|
The type of unit that the difference should be expressed in. When When
|
Returns
A Number which represents the count of
unit
units between start
and finish
.
Examples
The following query demonstrates several time differences:
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
System.out.println(
client.query(
Let(
"start", Time("1970-01-01T00:00:00+00:00"),
"finish", Now()
).in(
Arr(
TimeDiff(Date("1970-01-01"), ToDate(Now()), "days"),
TimeDiff(Var("start"), Var("finish"), "days"),
TimeDiff(Var("start"), Var("finish"), "half days"),
TimeDiff(Var("start"), Var("finish"), "hours"),
TimeDiff(Var("start"), Var("finish"), "minutes"),
TimeDiff(Var("start"), Var("finish"), "seconds"),
TimeDiff(Var("start"), Var("finish"), "milliseconds")
)
)
).get()
);
client.query(
q.Let(
{
'start': q.Time('1970-01-01T00:00:00+00:00'),
'finish': q.Now(),
},
[
q.TimeDiff(q.Date('1970-01-01'), q.ToDate(q.Now()), 'days'),
q.TimeDiff(q.Var('start'), q.Var('finish'), 'days'),
q.TimeDiff(q.Var('start'), q.Var('finish'), 'half days'),
q.TimeDiff(q.Var('start'), q.Var('finish'), 'hours'),
q.TimeDiff(q.Var('start'), q.Var('finish'), 'minutes'),
q.TimeDiff(q.Var('start'), q.Var('finish'), 'seconds'),
q.TimeDiff(q.Var('start'), q.Var('finish'), 'milliseconds'),
]
)
)
.then((ret) => console.log(ret))
Not available in this language yet.
Not available in this language yet.
println(Await.result(
client.query(
Let(
Seq(
"start" -> Time("1970-01-01T00:00:00+00:00"),
"finish" -> Now()
),
Arr(
TimeDiff(Date("1970-01-01"), ToDate(Now()), "days"),
TimeDiff(Var("start"), Var("finish"), "days"),
TimeDiff(Var("start"), Var("finish"), "half days"),
TimeDiff(Var("start"), Var("finish"), "hours"),
TimeDiff(Var("start"), Var("finish"), "minutes"),
TimeDiff(Var("start"), Var("finish"), "seconds"),
TimeDiff(Var("start"), Var("finish"), "milliseconds")
)
)
),
5.seconds
))
Not available in this language yet.
[18194, 18194, 36388, 436657, 26199422, 1571965360, 1571965360019]
[ 18194, 18194, 36388, 436657, 26199422, 1571965360, 1571965360019 ]
[18194, 18194, 36388, 436657, 26199422, 1571965360, 1571965360019]
Was this article helpful?
We're sorry to hear that.
Tell us how we can improve!
documentation@fauna.com
Thank you for your feedback!