I am trying to implement the solr query using .NET but i am getting bad request when i try to connect to the solr for search since my date format is wrong.Can any one tell me the exact syntax to create a date format in .net
Created_Dt :[12/12/2008 3:45 PM TO *]
SolrNet already does the conversion to Solr time format for you, you only need to work with the standard DateTime
type:
new SolrQueryByRange<DateTime?>("Created_Dt", new DateTime(2008, 12, 12, 15, 45, 0), null);
You need to search based on a UTC timestmap. Here is some example .NET code to generate it:
DateTime dt = DateTime.Now.ToUniversalTime();
System.Diagnostics.Debug.WriteLine(dt.ToString("yyyy-MM-ddTHH:mm:ssZ"));
And a query using your example field that would use that format:
Created_Dt:[2011-06-07T13:35:47Z TO NOW]
Also, make sure you convert your dates to UTC format before you store them.
I could get the solr date format using the code below,
DateTimeFieldSerializer date = new DateTimeFieldSerializer();
string fromDt = date.SerializeDate(searchCriteria.From);
string toDt = date.SerializeDate(searchCriteria.To);
This works fine and I can search using the date range now..