# Measuring days between dates

**URL:** <https://forum.inductiveautomation.com/t/measuring-days-between-dates/44085>\
**Category:** Ignition\
**Tags:** perspective, scripting, ignition79, ignition80\
**Created:** [March 4, 2021, 8:09am UTC](https://forum.inductiveautomation.com/t/measuring-days-between-dates/44085 "2021-03-04T08:09:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![berkay.cinar](https://avatars.discourse-cdn.com/v4/letter/b/b9bd4f/32.png) [@berkay.cinar](https://forum.inductiveautomation.com/u/berkay.cinar)\
**Post date:** [March 4, 2021, 8:09am UTC](https://forum.inductiveautomation.com/t/measuring-days-between-dates/44085/1 "2021-03-04T08:09:33Z")

</div>

Hello,

I am trying to get the days between 2 dates. First date is coming from a button press with this and I write it to date time memory tag.

time=system.date.now()  
system.tag.write("[TSW\_Production]Foaming/Denemeler/BakimZamani",(time))

Second date is coming from another value changed tag script like below and in the same value changed script I want to calculate the days between first date and second one. I want to write this day difference to another memory tag.

currenttime=system.date.now()  
ptime=system.tag.read("[.]…/…/Denemeler/BakimZamani")  
timedif=system.date.daysBetween(currenttime,ptime)  
system.tag.write("[.]…/…/Denemeler/Bakimakalansure",(timedif))

But I do get error like this

Error executing script.  
Traceback (most recent call last):  
File “tagevent:valueChanged”, line 4, in valueChanged  
TypeError: daysBetween(): 2nd arg can’t be coerced to java.util.Date

I think my first date which was written on a date time tag in a different event script cant get read properly in the system.date.daysBetween function. How can I get this to work?

Any help is much appreciated.

---

<div class="post-metadata">

**Author:** ![chi](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@chi](https://forum.inductiveautomation.com/u/chi)\
**Post date:** [March 4, 2021, 8:22am UTC](https://forum.inductiveautomation.com/t/measuring-days-between-dates/44085/2 "2021-03-04T08:22:00Z")

</div>

> [@berkay.cinar](#):
>
> ptime=system.tag.read("[.]…/…/Denemeler/BakimZamani")

`system.tag.read` returns a qualified value object. Use

> [@berkay.cinar](#):
>
> ptime=system.tag.read("[.]…/…/Denemeler/BakimZamani").value
