cancel
Showing results for 
Search instead for 
Did you mean: 

Lucene search date range MIN, NOW not working

shikarishambu
Champ in-the-making
Champ in-the-making
I am trying to use the MIN and NOW functions that are shown in the Search API syntax as part of my custom search webscript. However, I can't seem to get it working. How do I specify default lower and upperbounds for date ranges in search?

My webscript snippet is shown below
if (((createdFrom == "") || (createdFrom == null)) && ((createdTo != "") && (createdTo != null)))
{
   query = '+@cm\\:created:\[' + MIN + ' TO ' + fnToISO(createdTo) +  '] ' + query;
}

if ((createdFrom != "") && (createdFrom != null) && ((createdTo == "") || (createdTo == null)))
{
   query = '+@cm\\:created:\[' + fnToISO(createdFrom) + ' TO ' + NOW +  '] ' + query;
}

I tried to replace MIN with fnToISO('1/1/1900'), that works. However, replacing NOW with fnToISO(), results in an error. The function fnToISO is shown below.

function fnToISO(dt) { 
   var nDate = new Date(dt);
   return nDate.format("isoDateTime");
    }
1 REPLY 1

pcorliss
Champ in-the-making
Champ in-the-making
I had difficulty with the date range searching until I started using full date strings including time. Try the following format.

YYYYMMDDTHH:MMSmiley FrustratedS.000
example: 20100201T00:00Smiley FrustratedS.000