Year

Time( str )
Time( str )
Time( str )
Time( str )
Time( str )
Time( str )

Description

The Year function extracts the year from a Timestamp.

Parameters

Argument Type Definition and Requirements

timestamp

A timestamp.

Returns

A Number which represents the value of the year from the provided timestamp.

Examples

The query below returns the year from a timestamp:

client.Query(Year(Time("2019-04-29T12:51:17Z")));
2019
curl https://db.fauna.com/ \
    -u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
    -d '{ "year": { "time": "2019-04-29T12:51:17Z" } }'
HTTP/1.1 200 OK
{ "resource": 2019 }
result, _ := client.Query(f.Year(f.Time("2019-04-29T12:51:17Z")))
fmt.Println(result)
2019
System.out.println(
    client.query(
        Year(Time(Value("2019-04-29T12:51:17Z")))
    ).get()
);
2019
client.query(
  q.Year(q.Time('2019-04-29T12:51:17Z'))
)
.then((ret) => console.log(ret))
2019
result = client.query(q.year(q.time("2019-04-29T12:51:17Z")))
print(result)
2019
println(Await.result(
  client.query(Year(Time("2019-04-29T12:51:17Z"))),
  5.seconds
))
2019

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!