Alec Wenzowski
Alec Wenzowski

Reputation: 3908

How to express current date in MQL Freebase Query?

Freebase's metaweb query language can be used to retreive future events if you pass in an ISO8601 formatted date.

[{
  "id":            null,
  "name":          null,
  "start_date" :   null,
  "type":          "/time/event",
  "start_date>" :  "2011-09-02"
}]​

^ run this query

Does MQL support an equivalent to SQL's NOW() or CURDATE()?

Upvotes: 3

Views: 288

Answers (2)

Shawn Simister
Shawn Simister

Reputation: 4603

There is no equivalent to SQL's NOW() or CURDATE in MQL. Whichever programming language you're using to send the query should have an equivalent function which you can use.

You can kind of get a list of future events by sorting them in descending order of start_date like this:

[{
  "id":         null,
  "name":       null,
  "type":       "/time/event",
  "start_date": {
    "value":    null,
    "optional": false
  },
  "sort":       "-start_date.value"
}]​

Upvotes: 1

Michael Masouras
Michael Masouras

Reputation: 511

You can also use __now__ in timestamp fields as a special shortcut:

[{
  "id":            null,
  "name":          null,
  "start_date" :   null,
  "type":          "/time/event",
  "start_date>" :  "__now__"
}]​

You can see a live demo of this via this Freebase Query Editor snippet.

Upvotes: 4

Related Questions