Views sort criteria by date does not order properly

I have a drupal 7 site with the most recent updates to core and the views module. I am trying to build a view to show three pieces of content (training events) that should display the three most recent pieces of content, based on the date field set by the user corresponding to the date of a training event (i.e. the input date set by the user, not the date of the content’s creation). The date field to set to accept start and end times to show the duration of the event.

The view is based on the content type with the date field and I am trying to implement a sort criteria set on the date field in descending order. The issue I’m having is that the dates do not order as expected: the ordering that is output is as follows: March 7th, 2019; February 2nd, 2019; and then September 27th, 2016. The ordering is also incorrect for an ascending sort, with September 27th, 2016 followed by September 5th, 2016, and then February 2nd, 2019. The sort order seems to be incorrect regardless of which field I base sort ordering on (start date or end date), so I’m not sure what’s going on here. I don’t have the option to specify a granularity, so I’m not sure which value the dates are actually being ordered by. The ordering seems to disregard the ordering of months and individual dates, (e.g. ordering March before February in descending order, then ordering September 16th, 2016 before September 5th, 2016 in ascending order), so I’m not sure which value in the date the view is actually being sorted by. Any advice on how to approach this would be greatly appreciated.

Here is the export of the view:

$view = new view(); $view->name = 'upcoming_training_events'; $view->description = ''; $view->tag = 'default'; $view->base_table = 'node'; $view->human_name = 'Upcoming Training Events'; $view->core = 7; $view->api_version = '3.0'; $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */  /* Display: Master */ $handler = $view->new_display('default', 'Master', 'default'); $handler->display->display_options['title'] = 'Upcoming Training Events'; $handler->display->display_options['use_more_always'] = FALSE; $handler->display->display_options['access']['type'] = 'perm'; $handler->display->display_options['cache']['type'] = 'none'; $handler->display->display_options['query']['type'] = 'views_query'; $handler->display->display_options['exposed_form']['type'] = 'basic'; $handler->display->display_options['pager']['type'] = 'some'; $handler->display->display_options['pager']['options']['items_per_page'] = '5'; $handler->display->display_options['pager']['options']['offset'] = '0'; $handler->display->display_options['style_plugin'] = 'table'; $handler->display->display_options['style_options']['columns'] = array(   'title' => 'title',   'field_date_of_training' => 'field_date_of_training', ); $handler->display->display_options['style_options']['default'] = '-1'; $handler->display->display_options['style_options']['info'] = array(   'title' => array(     'sortable' => 0,     'default_sort_order' => 'asc',     'align' => '',     'separator' => '',     'empty_column' => 0,   ),   'field_date_of_training' => array(     'sortable' => 0,     'default_sort_order' => 'asc',     'align' => '',     'separator' => '',     'empty_column' => 0,   ), ); /* Field: Content: Title */ $handler->display->display_options['fields']['title']['id'] = 'title'; $handler->display->display_options['fields']['title']['table'] = 'node'; $handler->display->display_options['fields']['title']['field'] = 'title'; $handler->display->display_options['fields']['title']['label'] = ''; $handler->display->display_options['fields']['title']['alter']['text'] = '[title]'; $handler->display->display_options['fields']['title']['alter']['make_link'] = TRUE; $handler->display->display_options['fields']['title']['alter']['path'] = '[field_link_to_training]'; $handler->display->display_options['fields']['title']['alter']['absolute'] = TRUE; $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; $handler->display->display_options['fields']['title']['element_label_colon'] = FALSE; $handler->display->display_options['fields']['title']['link_to_node'] = FALSE; $handler->display->display_options['fields']['title']['node_in_colorbox_width'] = '600'; $handler->display->display_options['fields']['title']['node_in_colorbox_height'] = '600'; $handler->display->display_options['fields']['title']['node_in_colorbox_rel'] = ''; /* Field: Content: Training Description */ $handler->display->display_options['fields']['field_training_description']['id'] = 'field_training_description'; $handler->display->display_options['fields']['field_training_description']['table'] = 'field_data_field_training_description'; $handler->display->display_options['fields']['field_training_description']['field'] = 'field_training_description'; /* Field: Content: Date of Training */ $handler->display->display_options['fields']['field_date_of_training']['id'] = 'field_date_of_training'; $handler->display->display_options['fields']['field_date_of_training']['table'] = 'field_data_field_date_of_training'; $handler->display->display_options['fields']['field_date_of_training']['field'] = 'field_date_of_training'; $handler->display->display_options['fields']['field_date_of_training']['settings'] = array(   'format_type' => 'long',   'fromto' => 'both',   'multiple_number' => '',   'multiple_from' => '',   'multiple_to' => '',   'show_remaining_days' => 0, ); /* Field: Content: Link to Training */ $handler->display->display_options['fields']['field_link_to_training']['id'] = 'field_link_to_training'; $handler->display->display_options['fields']['field_link_to_training']['table'] = 'field_data_field_link_to_training'; $handler->display->display_options['fields']['field_link_to_training']['field'] = 'field_link_to_training'; $handler->display->display_options['fields']['field_link_to_training']['label'] = ''; $handler->display->display_options['fields']['field_link_to_training']['element_label_colon'] = FALSE; $handler->display->display_options['fields']['field_link_to_training']['click_sort_column'] = 'url'; $handler->display->display_options['fields']['field_link_to_training']['delta_offset'] = '0'; $handler->display->display_options['fields']['field_link_to_training']['multi_type'] = 'ul'; /* Sort criterion: Content: Date of Training -  start date (field_date_of_training) */ $handler->display->display_options['sorts']['field_date_of_training_value']['id'] = 'field_date_of_training_value'; $handler->display->display_options['sorts']['field_date_of_training_value']['table'] = 'field_data_field_date_of_training'; $handler->display->display_options['sorts']['field_date_of_training_value']['field'] = 'field_date_of_training_value'; $handler->display->display_options['sorts']['field_date_of_training_value']['order'] = 'DESC'; /* Filter criterion: Content: Published */ $handler->display->display_options['filters']['status']['id'] = 'status'; $handler->display->display_options['filters']['status']['table'] = 'node'; $handler->display->display_options['filters']['status']['field'] = 'status'; $handler->display->display_options['filters']['status']['value'] = 1; $handler->display->display_options['filters']['status']['group'] = 1; $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; /* Filter criterion: Content: Type */ $handler->display->display_options['filters']['type']['id'] = 'type'; $handler->display->display_options['filters']['type']['table'] = 'node'; $handler->display->display_options['filters']['type']['field'] = 'type'; $handler->display->display_options['filters']['type']['value'] = array(   'upcoming_training' => 'upcoming_training', );  /* Display: Block */ $handler = $view->new_display('block', 'Block', 'block'); 

UPDATE

Per comment request here are the results from drush pml grep|date Seems to be a conflict between date and commerce_cart

PHP Fatal error:  Only variables can be passed by reference in /var/www/html/phisigmarho.org/sites/all/modules/commerce/modules/cart/commerce_cart.module on line 1344 PHP Stack trace: PHP   1. {main}() /home/nizzok/.composer/vendor/drush/drush/drush.php:0 PHP   2. drush_main() /home/nizzok/.composer/vendor/drush/drush/drush.php:11 PHP   3. DrushBootBaseBoot->bootstrap_and_dispatch() /home/nizzok/.composer/vendor/drush/drush/drush.php:70 PHP   4. drush_bootstrap_to_phase() /home/nizzok/.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php:56 PHP   5. drush_bootstrap() /home/nizzok/.composer/vendor/drush/drush/includes/bootstrap.inc:429 PHP   6. DrushBootDrupalBoot7->bootstrap_drupal_full() /home/nizzok/.composer/vendor/drush/drush/includes/bootstrap.inc:313 PHP   7. drupal_bootstrap() /home/nizzok/.composer/vendor/drush/drush/lib/Drush/Boot/DrupalBoot7.php:74 PHP   8. _drupal_bootstrap_full() /var/www/html/phisigmarho.org/includes/bootstrap.inc:2523 PHP   9. module_load_all() /var/www/html/phisigmarho.org/includes/common.inc:5267 PHP  10. drupal_load() /var/www/html/phisigmarho.org/includes/module.inc:24 Drush command terminated abnormally due to an unrecoverable error.   [error] Error: Only variables can be passed by reference in /var/www/html/phisigmarho.org/sites/all/modules/commerce/modules/cart/commerce_cart.module, line 1344 
This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Views sort criteria by date does not order properly

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.