Why not just use a data type of "string" to create the range index? The various 
dates should then sort appropriately, unless you want bare year or year-month 
values to sort at the end. For example,

let $dates := ('2002-04-05','2002-04', '2001-09-11', '2001',
'2001-12-15', '2001-12', '2001-01', '2002')
for $date in $dates
order by $date
return <d>{$date}</d>

==> 2001 2001-01 2001-09-11 2001-12 2001-12-15 2002 2002-04 2002-04-05


On Wed, 4 Jun 2014, Jonathan Greenberg wrote:

> Hello all,
> We have created a TEI P5 schema for marking up Die Musik in Geschichte und
> Gegenwart, a large encyclopedia about music. We building a CMS with
> MarkLogic to manage the publication (which will be published online in
> 2017), and I'm running into a problem with indexing dates in MarkLogic.
> The (mostly birth- and death-) dates in MGG are not all the same: some have
> a month and day, others just a year. So  in the markup, some look like this:
> <birth><date when="2001-09-11">11. Sept 2001</date></birth>
> while others look like this: <date when="2001">2001</date>
> The problem is that is seems that MarkLogic cannot create a range index of
> these dates, because they are not all in the same format. The only solution
> I have come up with is to add a second attribute that would be normalized
> (perhaps a custom @year attribute), but wonder if there are any better
> solutions. Anyone have experience with this?
> Jonathan

David Sewell, Editorial and Technical Manager
ROTUNDA, The University of Virginia Press
PO Box 400314, Charlottesville, VA 22904-4314 USA
Email: [log in to unmask]   Tel: +1 434 924 9973