Answers.Body: <p>So you're not getting your matrix field's value properly. You're going to want to access it the same way you'd output the data:</p>
  
  <pre><code>{{ event.dates.type('date').first().startDate.getTimestamp() }}
  </code></pre>
  
  <p>So what we're doing here is getting the <code>dates</code> matrix field, selecting the blocks that have a type of <code>date</code>, getting the first of those blocks (should be our only block but <code>.first</code> is still needed), then get the <code>startDate</code> field in that block. During my testing I found you needed something like <code>.getTimestamp()</code> or <code>.atom()</code> to turn the date into a string that SuperSort could understand (not sure why the examples in our docs don't use that, will definitely look into that though).</p>
  
  <p>So something like this should achieve what you're looking for:</p>
  
  <pre><code>{% set pageEntries = craft.entries.section('events') | supersort('sortAs', '{dates.type("date").first.startDate.getTimestamp}') %}
  {% for event in pageEntries %}
      {# event data #}
  {% endfor %}
  </code></pre>
  
  <p>Hopefully that helps!</p>
  
  <blockquote>
    <p>Fwiw, I work for TopShelfCraft (who made the SuperSort plugin)</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-27T03:12:19.553Z
Answers.Text: Thanks! Seems like that's doing the trick for the problem I described, but my issue is a bit more complicated than I initially thought. I've edited the original question. Really appreciate your help!
Answers.UserDisplayName: Bryce
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-26T19:32:59.507Z
Answers.LastActivityDate: 2018-11-26T19:32:59.507Z
Answers.UserDisplayName: Jalen Davenport
Body: <p>I'm trying to use Supersort to sort entries using a date/time field within a matrix, for example 1/6/2019 12:00AM. These dates will always be in the future. I want to sort it so that the entries that are closest to happening are displayed first. </p>
  
  <p>To make it more complicated, entries with multiple dates in the matrix are split apart, so I need to sort each of these according to their date (from <a href="https://gocrowsnest.ca/events" rel="nofollow noreferrer">https://gocrowsnest.ca/events</a>):</p>
  
  <p><a href="https://i.sstatic.net/UpcsA.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/UpcsA.png" alt="https://gocrowsnest.ca/events"></a></p>
  
  <p>I can't figure out how exactly I'm supposed to do this. What I have: </p>
  
  <pre><code>{% set pageEntries = craft.entries.section('events') | supersort('sortAs', '{dates.type("date").first.startDate.getTimestamp}') %}
  {% for event in pageEntries %}
      {% for block in event.dates.all() %}
          {# Event code #}
      {% endfor %}
  {% endfor %}
  </code></pre>
  
  <p>This is sorting each entry by the first matrix date, not by each date.</p>
  
  <p>Matrix handle: dates, block: date, field (date/time): startDate.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-11-24T22:42:32.523Z
Comments.Text: Can you elaborate on what you mean by sorting by a field in a matrix block? Presumably the matrix date field has a date in it... but how are you wanting to use that to sort entries in a channel? If I have 2018.11.25 in a date field, how would this apply to sorting entries?
Comments.UserDisplayName: andrew.welch
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-11-26T02:40:09.760Z
Comments.Text: Updated with more context.
Comments.UserDisplayName: Bryce
Tags: <plugin-supersort>
Title: Using a matrix Date/Time field to sort entries
ThreadText: # Using a matrix Date/Time field to sort entries
  
  (Asked by: username_0 on 2018-11-24)
  
  I'm trying to use Supersort to sort entries using a date/time field within a matrix, for example 1/6/2019 12:00AM. These dates will always be in the future. I want to sort it so that the entries that are closest to happening are displayed first.
  
  To make it more complicated, entries with multiple dates in the matrix are split apart, so I need to sort each of these according to their date (from <https://gocrowsnest.ca/events>):
  
  [![https://gocrowsnest.ca/events](https://i.sstatic.net/UpcsA.png)](https://i.sstatic.net/UpcsA.png)
  
  I can't figure out how exactly I'm supposed to do this. What I have:
  
  ```
  {% set pageEntries = craft.entries.section('events') | supersort('sortAs', '{dates.type("date").first.startDate.getTimestamp}') %}
  {% for event in pageEntries %}
      {% for block in event.dates.all() %}
          {# Event code #}
      {% endfor %}
  {% endfor %}
  
  ```
  
  This is sorting each entry by the first matrix date, not by each date.
  
  Matrix handle: dates, block: date, field (date/time): startDate.
  
  **Tags:** plugin-supersort
  
  > **Comments:**
  > **username_1**: Can you elaborate on what you mean by sorting by a field in a matrix block? Presumably the matrix date field has a date in it... but how are you wanting to use that to sort entries in a channel? If I have 2018.11.25 in a date field, how would this apply to sorting entries?  
  > **username_0**: Updated with more context.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-11-26. Score: 1
  
  So you're not getting your matrix field's value properly. You're going to want to access it the same way you'd output the data:
  
  ```
  {{ event.dates.type('date').first().startDate.getTimestamp() }}
  
  ```
  
  So what we're doing here is getting the `dates` matrix field, selecting the blocks that have a type of `date`, getting the first of those blocks (should be our only block but `.first` is still needed), then get the `startDate` field in that block. During my testing I found you needed something like `.getTimestamp()` or `.atom()` to turn the date into a string that SuperSort could understand (not sure why the examples in our docs don't use that, will definitely look into that though).
  
  So something like this should achieve what you're looking for:
  
  ```
  {% set pageEntries = craft.entries.section('events') | supersort('sortAs', '{dates.type("date").first.startDate.getTimestamp}') %}
  {% for event in pageEntries %}
      {# event data #}
  {% endfor %}
  
  ```
  
  Hopefully that helps!
  
  > Fwiw, I work for TopShelfCraft (who made the SuperSort plugin)
  
  > **Comments:**
  > **username_0**: Thanks! Seems like that's doing the trick for the problem I described, but my issue is a bit more complicated than I initially thought. I've edited the original question. Really appreciate your help!  
  
  ---
  
  