<p>Craft always saves a complete DateTime value to the database, even if you only make it set / show the time part of it in the Control Panel.</p>

<p>To ignore the date part (which in this case is set to the day you saved your entry) within the <code>order</code> parameter, you can make use of the <a href="http://dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html#function_time" rel="noreferrer"><code>time()</code></a> MySQL function:</p>

<pre><code>{% set entries = craft.entries.section('events').order('eventDate', 'time(eventStart)') %}
</code></pre>

CC BY-SA 3.0
2016-01-21T13:14:39.353Z
That "time()" function inside the order did the trick for me. Couldn't figure out why it couldn't order correctly from a time field.
Ole
CC BY-SA 3.0
2015-01-19T08:22:24.857Z
2015-01-19T08:22:24.857Z
carlcs
<p>I've got an events listings which works pretty well and there is a:</p>

<ul>
<li>Custom Date field, eventEnd (just date)</li>
<li>Custom Start Time, eventStart (just time)</li>
<li>Custom End Time, eventEnd (just time)</li>
</ul>

<p>I can list these entries so we list by date then time by using:</p>

<pre><code>{% for entry in craft.entries.section('events').order('eventDate', 'eventStart').find() %}
</code></pre>

<p>but eventStart is ignored altogether, even when I would use:</p>

<pre><code>{% for entry in craft.entries.section('events').order('eventStart').find() %}
</code></pre>

<p>I would expect:</p>

<p>Event 1: 14:00
Event 2: 15:00
Event 3: 16:00</p>

<p>but instead get something more random based I think on post date.</p>

<p>Suggestions welcome thank you!</p>

<p>UPDATE:</p>

<p>my biggest issue is actually being able to list by eventStart at all. Just using {{ eventStart }} reveals the current date. But if I try to boil down to just the hour, it's not a recognised way of ordering (even though it's just a set of numbers?)</p>

<p>So, I'm not sure where to head with this. I'm sure that if my start time was bundled in with the main date, all would be fine, but it makes the system a bit less obvious and flexible.</p>

<p>Here's what I've tried:</p>

<pre><code>{% set completeeventlist = craft.entries.section('events') %}
{% for x in craft.entries(completeeventlist).order('eventDate') %}
&lt;ul&gt;
    {% set es = x.eventStart|date('H') %}
        {% for entry in craft.entries(x).order(es) %}
        &lt;li&gt;{{ entry.id }}{{ es }}&lt;/li&gt;
    {% endfor %}
&lt;/ul&gt;
{% endfor %}
</code></pre>

CC BY-SA 3.0
2015-01-15T11:45:39.697Z
Have you tried: `{% for entry in craft.entries.section('events').order('eventDate, eventStart').find() %}`
Luke Holder
CC BY-SA 3.0
2015-01-15T13:58:26.747Z
Tried that - throws an error CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'eventStart' in 'order clause'
Simon Clayson
CC BY-SA 3.0
2015-01-15T14:00:15.830Z
eventStart is defiantly there, just ignored though as something to order from.
Simon Clayson
CC BY-SA 3.0
2015-01-15T14:50:20.977Z
is it a custom fieldType from a plugin?
Luke Holder
CC BY-SA 3.0
2015-01-15T19:09:32.100Z
No, just a normal datetime field. It's a custom field, but it's just the time.
Simon Clayson
CC BY-SA 3.0
2015-01-15T19:10:06.817Z
Also tried renaming the field. But that's not doing either.
Simon Clayson
CC BY-SA 3.0
2015-01-16T06:56:13.963Z
What I can't work out here is if even though they maybe separate custom fields, they sort of are. Generally, if I just order by eventDate then it all defaults next to the hour set, but then there's some entries where this fall foul.

Possibly a way, if I could set just the hour - like {% set es = entry.eventStart|date('H') %} and then order.('es') could take out any datetime variables. Need to work this out though!
Simon Clayson
<entries><order>
Order entries by custom time field
# Order entries by custom time field

(Asked by: username_0 on 2015-01-15)

I've got an events listings which works pretty well and there is a:

Custom Date field, eventEnd (just date)
Custom Start Time, eventStart (just time)
Custom End Time, eventEnd (just time)

I can list these entries so we list by date then time by using:
{% for entry in craft.entries.section('events').order('eventDate', 'eventStart').find() %}

but eventStart is ignored altogether, even when I would use:
{% for entry in craft.entries.section('events').order('eventStart').find() %}

I would expect:
Event 1: 14:00
Event 2: 15:00
Event 3: 16:00
but instead get something more random based I think on post date.
Suggestions welcome thank you!
UPDATE:
my biggest issue is actually being able to list by eventStart at all. Just using {{ eventStart }} reveals the current date. But if I try to boil down to just the hour, it's not a recognised way of ordering (even though it's just a set of numbers?)
So, I'm not sure where to head with this. I'm sure that if my start time was bundled in with the main date, all would be fine, but it makes the system a bit less obvious and flexible.
Here's what I've tried:
{% set completeeventlist = craft.entries.section('events') %}
{% for x in craft.entries(completeeventlist).order('eventDate') %}

    {% set es = x.eventStart|date('H') %}
        {% for entry in craft.entries(x).order(es) %}
        {{ entry.id }}{{ es }}
    {% endfor %}

{% endfor %}

**Tags:** entries, order

> **Comments:**
> **username_1**: Have you tried: `{% for entry in craft.entries.section('events').order('eventDate, eventStart').find() %}`  
> **username_0**: Tried that - throws an error CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'eventStart' in 'order clause'  
> **username_0**: eventStart is defiantly there, just ignored though as something to order from.  
> **username_1**: is it a custom fieldType from a plugin?  
> **username_0**: No, just a normal datetime field. It's a custom field, but it's just the time.  
> **username_0**: Also tried renaming the field. But that's not doing either.  
> **username_0**: What I can't work out here is if even though they maybe separate custom fields, they sort of are. Generally, if I just order by eventDate then it all defaults next to the hour set, but then there's some entries where this fall foul.  Possibly a way, if I could set just the hour - like {% set es = entry.eventStart|date('H') %} and then order.('es') could take out any datetime variables. Need to work this out though!  

---

## 1 answers

### Answer by username_2 on 2015-01-19. Score: 4 | Accepted answer

Craft always saves a complete DateTime value to the database, even if you only make it set / show the time part of it in the Control Panel.
To ignore the date part (which in this case is set to the day you saved your entry) within the order parameter, you can make use of the time() MySQL function:
{% set entries = craft.entries.section('events').order('eventDate', 'time(eventStart)') %}

> **Comments:**
> **username_3**: That "time()" function inside the order did the trick for me. Couldn't figure out why it couldn't order correctly from a time field.  

---

