XQuery/Time Based Queries

Motivation
You want to find items in a collection based on date-time information.

Method
By default, XML files use standard ISO dateTime structures to store temporal information. There are two main XML data types related to storing time:

xs:date - for storing just the date in YYYY-MM-DD format. xs:dateTime - for storing both the date and time.

There are many other structures for storing just year, month, day and time etc. but this example will only cover dates and dateTimes.

Sample Event Structure
In the following example we will store "event" data using a simple date structures. Events will have just a single start date or a date range with a start date and end date:

You can find all events that are occurring during any specific point in time with the following xquery structure.

Source from events-at-time.xq

You can also set up very fast searches based on the date-time structures even for large collections of 100,000 items after you learn how to configure range indexes on XML xs:dateTime structures. See: http://www.w3.org/TR/xmlschema-2/#dateTime how date-time structures work.

Other Resources

 * Timeline mashups in this Wikibook
 * Gantt Chart using JQuery
 * Timeline SVG reports
 * Gantt Charts from XML data using Anychart