Loading...
 
Skip to main content

Error warning: Divide by zero on "0"

Status
Closed
Subject
Error warning: Divide by zero on "0"
Version
21.x
Category
  • Usability
Feature
Trackers
Resolution status
Works For Me
Submitted by
Mike Finko
Keep informed
Jonny Bradley, Victor Emanouilov
Lastmod by
Mike Finko
Rating
(0)
Related-to
Description

This error message is from Tracker Mathematical Calculations.

This warning keeps popping up - can the warning be eliminated? Or, if I am incorrect and my mathematical calculation should instead be corrected, please advise.

Copy to clipboard
(round(div(div(date (sub futureDate (date)))60)60)1)


See more notes I added in the 'Forums' here - https://tiki.org/forumthread75298--Divide-by-Zero-warning

This is important because Tiki 21x is the latest LTS.

Adding Jonny and Victor as it seems you both tried to correct the issue.

thanks,
Mike

Workaround

See the 'Related' item for Bernard Sfez's post - Jonny's recommended workaround also worked in this situation:

"The workaround I did was to add an 'if' around it (which I think is good practice anyway), e.g."

Copy to clipboard
(if childrenBirthDate (round (div (sub (date) childrenBirthDate) 31536000 ) 1))


In my situation this is what the mathematical formula looks like:

Copy to clipboard
(if futureDate (round(div(div(date (sub futureDate (date)))60)60)1))


So with this formula, no more 'Divide by '0'' error messages.

Though I have no idea how it works or why, it seems as though this is not a TIki problem but an issue of how my mathematical formula was incorrectly put together.

Importance
7
Easy to solve?
5
Priority
35
Demonstrate Bug on Tiki 19+
Demonstrate Bug (older Tiki versions)
Ticket ID
7590
Created
Monday 02 November, 2020 12:52:45 UTC
by Mike Finko
LastModif
Monday 02 November, 2020 19:54:27 UTC


Show PHP error messages