title: How to order data by ONLY Hour:Minute format in MongoDB/Mongoid? (Without date!)
body: <p>I'm using MongoDB and Mongoid in my project. I have some difficulties with ordering "Time" field data.</p>
  
  <p>As you know, eventhough you set a field type as <code>Time</code> inside your Mongoid Document, time data is stored as this format (note that I use +2 hours offset to get my own timezone's time instead of UTC):</p>
  
  <p><code>Mon, 31 Dec 2012 08:30:00 EET +02:00</code></p>
  
  <p>I'm not sure if I'm missing something but this is what happens to me.</p>
  
  <p>I want to use that <code>Time</code> data inside one of my views. I need to sort some related stuff by ONLY <code>Hour:Minute</code> format. I don't want Rails to take care of the DATE part of the field data. Because whenever a new <code>Time</code> record inserted to DB, it takes the day info as CURRENT DAY. </p>
  
  <h2>Issue is:</h2>
  
  <p>Because of it saves CURRENT DAY for each of new <code>Time</code> records, when I try to <code>order_by("hour DESC")</code> NEW records always retrieved first eventhough HOUR part of the data is bigger! </p>
  
  <h2>For example:</h2>
  
  <pre><code>First data:
  =&gt; Tue, 27 Nov 2012 19:50:00 EET +02:00
  Second data:
  =&gt; Mon, 24 Dec 2012 18:45:00 EET +02:00
  </code></pre>
  
  <p>As you know, normally, 19:50 is bigger than 18:45. But in this scenario, because of Rails takes <code>day</code> info into calculation, 18:45 looks like bigger than 19:50!</p>
  
  <p>So what is the work around for this issue?</p>
  
  <p>Thanks in advence.</p>