Grouping entries taking into account only the date, but not time


Hi. On our site we list events that are sorted by date. To each event there is associated a page with additional information and a date field. I would like to group these events into three groups: future events (i.e., events happening tomorrow or later), events happening today, past events (i.e., events that happened yesterday or earlier). I understand that I could use the where function in the form

{{ $past := where $events.ByDate .Date “lt” now }}

But I would like to group by day, which (I think) would require something like

{{ $past := where $events.ByDate .Date.Format “2006-01-02” “lt” now.Format “2006-01-02” }}

This does not work, however (even with putting parentheses in various places around the format). Is there a possibility to accomplish grouping by day? Thanks a lot for any help.




This is how you group by date:

Your current code is ordering by date: