Report Period conditions use timezone offset for Date field types #4876

Open
opened 2026-02-20 16:25:31 -05:00 by deekerman · 0 comments
Owner

Originally created by @ojs87 on GitHub (Oct 26, 2022).

Issue

When a User has set a different timezone and they attempt to report on Date fields, the CRM queries the database using a datetime value with an offset for the timezone. This provides incorrect results as the query will assume a date type has a midnight timestamp.

Expected Behavior

When the the user has set a timezone that is not the same as the database timezone.
The Date Period condition will return the correct results for "Today", "Yesterday" etc

Actual Behavior

When the the user has set a timezone that is not the same as the database timezone.
Date Period conditions of "Yesterday" will return dates from "Today" if the timezone is behind the db timezone.

Possible Fix

If the field type is "datetime" then provide an offset value, else use the midnight value for "date"

Steps to Reproduce

  1. Set your timezone to America/Chicago in your profile.
  2. Create a date field in Contacts
  3. Create a Contacts record with the newly created date field set to today.
  4. Create a Report on Contacts with a condition on the newly created date field equal to the period "Today"
  5. The Contacts record will not be returned in the report

Context

Your Environment

  • SuiteCRM Version used: SuiteCRM 7.12.7
  • Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): Firefox 105
  • Environment name and version (e.g. MySQL, PHP 7): PHP7.4
  • Operating System and version (e.g Ubuntu 16.04): Ubuntu 20.0.5
Originally created by @ojs87 on GitHub (Oct 26, 2022). <!--- Provide a general summary of the issue in the **Title** above --> <!--- Before you open an issue, please check if a similar issue already exists or has been closed before. ---> <!--- If you have discovered a security risk please report it by emailing security@suitecrm.com. This will be delivered to the product team who handle security issues. Please don't disclose security bugs publicly until they have been handled by the security team. ---> <!--- Please be aware that as of the 31st January 2022 we no longer support 7.10.x. New issues referring to 7.10.x will only be valid if applicable to 7.12.x and above. If your issue is still applicable in 7.12.x, please create the issue following the template below --> #### Issue <!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug --> <!--- Ensure that all code ``` is surrounded ``` by triple back quotes. This can also be done over multiple lines --> When a User has set a different timezone and they attempt to report on Date fields, the CRM queries the database using a datetime value with an offset for the timezone. This provides incorrect results as the query will assume a date type has a midnight timestamp. #### Expected Behavior When the the user has set a timezone that is not the same as the database timezone. The Date Period condition will return the correct results for "Today", "Yesterday" etc #### Actual Behavior <!--- Tell us what happens instead --> <!--- Also please check relevant logs (suitecrm.log, php error.log etc.) --> When the the user has set a timezone that is not the same as the database timezone. Date Period conditions of "Yesterday" will return dates from "Today" if the timezone is behind the db timezone. #### Possible Fix <!--- Not obligatory, but suggest a fix or reason for the bug --> If the field type is "datetime" then provide an offset value, else use the midnight value for "date" #### Steps to Reproduce <!--- Provide a link to a live example, or an unambiguous set of steps to --> <!--- reproduce this bug include code to reproduce, if relevant --> 1. Set your timezone to America/Chicago in your profile. 2. Create a date field in Contacts 3. Create a Contacts record with the newly created date field set to today. 4. Create a Report on Contacts with a condition on the newly created date field equal to the period "Today" 5. The Contacts record will not be returned in the report #### Context <!--- How has this bug affected you? What were you trying to accomplish? --> <!--- If you feel this should be a low/medium/high priority then please state so --> #### Your Environment <!--- Include as many relevant details about the environment you experienced the bug in --> * SuiteCRM Version used: SuiteCRM 7.12.7 * Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): Firefox 105 * Environment name and version (e.g. MySQL, PHP 7): PHP7.4 * Operating System and version (e.g Ubuntu 16.04): Ubuntu 20.0.5
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SuiteCRM-SuiteCRM#4876
No description provided.