Using Views Date Format SQL options on custom date fields

Created on 8 June 2018, over 6 years ago
Updated 13 February 2024, 9 months ago

This is a great module, so thanks very much. We have a use-case for this module where we wanted to use it for our custom tables in our D8 database. They are using timestamps and so we weren't able to use aggregation as we wanted. However, we are using this with "Date" fields - I saw there's a few issues relating to the D7 version of this module, and have searched through the D8 issues, so sorry if this is a duplicate.

I've got it working for our data structure and will post a patch that hopefully is useful for somebody!

Feature request
Status

Needs review

Version

3.0

Component

Code

Created by

🇬🇧United Kingdom littlepixiez

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇬🇧United Kingdom fonant

    Works for me with Drupal 9 if I patch with #3 then #18.

  • Issue was unassigned.
  • 🇮🇳India mukhtarm

    Hi I am using D9.5 and here is the patch that works for the custom date fields (I combined the #18 and #3 basically, but there were some tweaks needed as #18 was not applying cleanly). It works well to apply the custom SQL format to the custom field. Thanks

  • 🇵🇹Portugal lolgm

    I'm using D10.1 and patch #22 is working as expected, however, I'm getting the following warning:

    Trying to access array offset on value of type null views_date_format_sql.views.inc:34
    Undefined array key "field" views_date_format_sql.views.inc:34
    

    The attached patch fixes this problem.

  • 🇮🇳India mukhtarm

    Thanks for the update @lolgm

  • 🇵🇹Portugal lolgm

    @MukhtarM I'm having a problem with the patch.
    It seems to me that something went wrong with the combination of patch #3 and #18.
    The code below is referencing a plugin that does not exist in the current patch.

    if (!empty($field['field']['id']) && $field['field']['id'] === 'date') {
      $field['field']['id'] = 'views_date_format_sql_date';
    }
    

    Could we remove this one?

  • Status changed to Needs review 12 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 12 months ago
    4 pass, 1 fail
  • 🇮🇳India mukhtarm

    @lolgm Actually the patch didn't included the new plugin file (my bad :( ). Corrected it and included your changes also. thanks.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 8.1 & MySQL 5.7
    last update 12 months ago
    4 pass, 1 fail
  • 🇬🇧United Kingdom fonant

    Patch in #26 applies cleanly to 3.x-dev and fixes the problem, Drupal 10. Thanks @MukhtarM!

  • First commit to issue fork.
Production build 0.71.5 2024