Day Diffrerence between two dates


Can anyone tell me how can I calculate the difference between two dates without using the hours
difference.suppose if date1 is “2017-08-16 6:00:00” and date2 is “2017-08-17 1:00:00”.So according to hours calculation using Sub method it will give me 1 day.But I want here 2 day as date is different. So please let me know if there is a way to do it.

Current Sample Code:-

remainingdaydiff := endDateTime.Sub(todayNow)
remainingdays := uint(remainingdaydiff.Hours() / 24)

You want 17 minus 16 to equal 2?

@calmh yes for date purpose.Means it should calculate 16 as well as 17.

I guess truncate to the date, subtract, add one:

1 Like

@calmh Thank you so much.It really worked for me.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.