Date

Date( str )
Date( str )
Date( str )
Date( str )
date( str )
Date( str )

Description

The Date function constructs a Date from an ISO 8601 formatted date string.

Date only accepts a date string. An error occurs if you include any time information.

Parameters

Argument Type Definition and Requirements

str

An ISO 8601 formatted date string.

Returns

A Date type which represents the converted string.

Examples

The following query returns a Date constructed from the provided string:

client.Query(Date("1970-01-01"));
{ "@date": "1970-01-01" }
curl https://db.fauna.com/ \
    -u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
    -d '{ "date": "1970-01-01" }'
HTTP/1.1 200 OK
{ "resource": { "@date": "1970-01-01" } }
result, _ := client.Query(f.Date("1970-01-01"))
fmt.Println(result)
{0 62135596800 <nil>}
System.out.println( client.query(Date(Value("1970-01-01"))).get());
1970-01-01
client.query(q.Date('1970-01-01'))
.then((ret) => console.log(ret))
FaunaDate { value: '1970-01-01' }
result = client.query(q.date("1970-01-01"))
print(result)
1970-01-01
client.query(Date("1970-01-01"))
1970-01-01

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!