datescilab

How to calculate number of days between dates?


I have the date array dateGas = ["09/28/2013", "10/10/2013"]; I want to calculate the number of full days between the two dates. Using this:

d1 = datetime(dateGas(1), "InputFormat", "mm/dd/yyyy")
d2 = datetime(dateGas(2), "InputFormat", "mm/dd/yyyy")
delta = days(d2-d1)

will result in delta = 17.999306 which is obviously wrong. What do I miss here?

Thanks!


Solution

  • The format mm is for minutes, MM is for month. Your datetime will have the same month, and the difference between the 28th and the 10th is 18 days.