Drupal 7

I have a view that sorts on three fields so the ORDER BY statement looks like: ORDER BY

node_status ASC, field_data_field_date_field_date_value DESC, field_data_field_sort_order_field_sort_order_value ASC

I need the sort of the date field to not be granular to the time. I just want it sorted by the date so that the sort order field will take it from there. When I run the query against the database itself, I see that the date field returned is showing the full value like: 2016-06-19 08:48:12, but some of the values are different by a second, causing the "incorrect" (not the desired) sort order.

How can I get it to sort on the date field (date field module) without the "full date" field?

EDIT: (adding screen shot of view) enter image description here

2 Answers 2


D7 only provides granularity for the core fields not added fields.

D8 provides granularity for the core and added fields.

I have added D7 functionality as a patch to the module views_date_format_sql. See this patch.

Views_date_format_sql can also do custom formats as well.


  • The D8 patch is only for core date fields so far (e.g. node updated).

you can change the granularity of the sort under the settings for the sort criteria:

enter image description here

  • I don't see the settings to click on to get that. I added a screen shot of my view to my question. I do have it for the filter on date.
    – shelane
    Jun 19, 2015 at 17:51
  • If you're using the Date Module, you can set the granularity in the Field Settings for that particular field
    – Geoff
    Jun 19, 2015 at 18:23
  • It is a date field with the date module and the field is defined as only collecting month, day, and year. I wish I knew why I wasn't seeing what you see for those settings.
    – shelane
    Jun 19, 2015 at 18:29
  • We have now done a work-around. We have rules applied when these items are published to set the date. It was getting set with "now" and I have changed it to "today" and it is just setting the field with the midnight time.
    – shelane
    Jun 19, 2015 at 18:31
  • well, if it works... you aren't seeing what I posted because you didn't specify you were using the Date Field module, the image I posted is for core Post Date Field
    – Geoff
    Jun 19, 2015 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.