• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Calculate leave days based on leaveStart and leaveEnd

I am trying to calculate the total leave days based on two dates. I tried using datediff and timestampdiff but it gives me the wrong result.
For example I input:
leaveStart = "2022-04-26"
leaveEnd = "2022-04-27"

So the total leave days should be 2 days because the leave is from 26 to 27.

datediff and timestampdiff basically gives me the difference between two dates.
Any ideas how to compute it properly? I may try adding 1 day to the result but i just want to know if there's a better way to do it.
 
Top