Integer diff(DateTime otherDateTime)

Doesent this function work anymore ?

RE: Integer diff(DateTime otherDateTime)

Yes, it still works.

DateTime dtStart;
dtStart.addDay(-3);

DateTime dtEnd;

Integer diffSeconds = dtEnd.diff(dtStart);
Integer diffMinutes = diffSeconds / 60;
Integer diffHours = diffMinutes / 60;
Integer diffDays = diffHours / 24;


print("Seconds: " + diffSeconds.toString() + "\n");
print("Minutes: " + diffMinutes.toString() + "\n");
print("Hours: " + diffHours.toString() + "\n");
print("Days: " + diffDays.toString() + "\n");

 

Output will be:

Seconds: 259200
Minutes: 4320
Hours: 72
Days: 3
Av: Simen Mostuen Iversen 9. apr 2018

RE: Integer diff(DateTime otherDateTime)

I was trying to call the function in a wrong way (ie. diff(firstDateTIme, secondDateTime)

Thanks.

Av: Ummair Tahir 9. apr 2018