I am struggling with a query using DateTime type. Everything works fine using Date but if I test a DateTime input I get no match on my query.
I have (working example):
from content-type.xsml —> input name=“publishdate” type=“Date”*
var d = new Date();
var now = d.toISOString();
var query = "_parentPath = '/content/nibio/nyheter' AND data.publishdate < dateTime('" + now + "');
var result = execute('content.query', {
start: start,
count: count,
sort: 'data.publishdate DESC',
query: query,
contentTypes: [module.name + ':article']
});
I want
from content-type.xsml —> input name=“publishdatetime” type=“DateTime”*
In either case, if you get no hits using datetime, maybe you are trying to query against a localDateTime-field? In 5.x to keep backward compatability, the default datetime input has no timezone, and is of type localDateTime. Then it is not possible to query against a value with timezone, since this make no sense (localDateTime is not a point on the timeline, while d.doISOString() gives a point on the timeline)
To enable the input to be of time LocalDateTime, add this config to your content-type definition: