title: Date range query with lucene
body: <p>I am trying to take data between specific date ranges from mssql db. But returns nothing. I found a solution here on stackoverflow but it is not working. </p>
  
  <p>Here what I have done :</p>
  
  <p>This is the date field from the entity class: </p>
  
  <pre><code> @Basic(optional = false)
  @Column(name = "tarih")
  @Temporal(TemporalType.TIMESTAMP)
  @DateBridge(resolution = Resolution.MILLISECOND)
  private Date tarih;
  </code></pre>
  
  <p>This is how I am trying to take date between specific dates: </p>
  
  <pre><code> SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
      Calendar cal = Calendar.getInstance();
  
      Calendar cal2 = new GregorianCalendar();
      cal2.setTime(new Date(114, 12, 15, 3, 4,4));
  
  
      System.out.println(dateFormat.format(cal.getTime()));
      System.out.println(dateFormat.format(cal2.getTime()));
  
  
      TermRangeQuery luceneRangeDateQuery = newStringRange("tarih", DateTools.dateToString(cal2.getTime(), DateTools.Resolution.MILLISECOND),
       DateTools.dateToString(cal.getTime(), DateTools.Resolution.MILLISECOND), true, true);
      org.hibernate.Query fullTextQuery = fullTextSession.createFullTextQuery(luceneRangeDateQuery);
  
  
      List&lt;Satislar&gt; kayitliSatislar = fullTextQuery.list();
  </code></pre>
  
  <p>This is db record and it is type is datetime:</p>
  
  <p><a href="https://i.stack.imgur.com/i9vrZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i9vrZ.png" alt="This is db record and it is type is datetime:"></a></p>
  
  <p>This is the output these 2 lines and query sent: </p>
  
  <pre><code>    System.out.println(dateFormat.format(cal.getTime()));
      System.out.println(dateFormat.format(cal2.getTime()));
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/kw16q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kw16q.png" alt="enter image description here"></a></p>