I think that previous posts determined that you do not have GNU "date".
What Operating System are you using?
What Shell are you using?
Do you have "perl"?
Somebody here may give you a simple subtraction algorithm -- which will fail sometimes. What you need is something more robust.
What DBMS are you using? - many of them provide date subtraction that works reliably.
Plus you can get date/times in formats like Julian days which are floating point numbers.
You can use bc to do the arithmetic operation on these numbers
The reason for waffling is that you have to convert both dates into something like epoch seconds, then subtract, and return days, hours, minutes & seconds. You can do this in perl. It is just loads easier inside most modern dbms. Plus your perl may not have DateTime::Format::strptime.
If feasible, fetch the two dates as well as their difference from the database itself. That way you prevent the problem from becoming a bigger problem.