# Calculate leave days based on leaveStart and leaveEnd

#### Roy Harper

##### Coder
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.

I think use text format to break it into year, month, and day, then difference for each, then how long a month or year is in days each, then have result. You may break using 0 to first index of - and then firat index of - +1 to last index of - then last index of - +1 to end and be sure to test for valid numbers. Sorry if you wanted code written for you. You could use an array or rule set for days in a month and every 4 years is a leap year. X E.