# Subtracting dates

**URL:** <https://forum.inductiveautomation.com/t/subtracting-dates/86378>\
**Category:** Ignition\
**Created:** [February 26, 2024, 5:34pm UTC](https://forum.inductiveautomation.com/t/subtracting-dates/86378 "2024-02-26T17:34:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gfeiten](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@gfeiten](https://forum.inductiveautomation.com/u/gfeiten)\
**Post date:** [February 26, 2024, 5:34pm UTC](https://forum.inductiveautomation.com/t/subtracting-dates/86378/1 "2024-02-26T17:34:03Z")

</div>

Forgive me if I am missing something obvious, but is there a way to subtract one java.util.Date from another to compute a duration? I don't see anything in the system.date functions that would accomplish that.

alternatively can I convert java.util.Date to python datetime so I can use that library?

I have been pounding my head against the wall all morning, but it is Monday 😊

Thanks!

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [February 26, 2024, 5:40pm UTC](https://forum.inductiveautomation.com/t/subtracting-dates/86378/2 "2024-02-26T17:40:36Z")

</div>

Sure there is, use the `system.date.*Between()` functions. For instance if you want to know the hours between two dates, then you would do something like:

```auto
system.date.hoursBetween(firstDate,secondDate)

```

> **[system.date.\*Between | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-date/system-date-between)**
>
> Calculates the amount of time between two dates.

---

<div class="post-metadata">

**Author:** ![gfeiten](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@gfeiten](https://forum.inductiveautomation.com/u/gfeiten)\
**Post date:** [February 26, 2024, 7:05pm UTC](https://forum.inductiveautomation.com/t/subtracting-dates/86378/3 "2024-02-26T19:05:22Z")

</div>

That worked, thank you!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 26, 2024, 7:22pm UTC](https://forum.inductiveautomation.com/t/subtracting-dates/86378/4 "2024-02-26T19:22:09Z")

</div>

> [@gfeiten](#):
>
> python datetime

Psst! Don't ever use this in jython--it isn't up to date and never will be.
