# Getting Error while calculating differences between dates

**URL:** <https://forum.electroneek.com/t/getting-error-while-calculating-differences-between-dates/1785>\
**Category:** Studio Pro\
**Tags:** date, excel\
**Created:** [December 21, 2022, 9:00pm UTC](https://forum.electroneek.com/t/getting-error-while-calculating-differences-between-dates/1785 "2022-12-21T21:00:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![achyu](https://forum.electroneek.com/user_avatar/forum.electroneek.com/achyu/32/842_2.png) [@achyu](https://forum.electroneek.com/u/achyu)\
**Post date:** [December 21, 2022, 9:00pm UTC](https://forum.electroneek.com/t/getting-error-while-calculating-differences-between-dates/1785/1 "2022-12-21T21:00:00Z")

</div>

Hello All,

I’m getting an error while calculating the differences between current date and the date from my excel (end\_day). Both formats are same (YYYY-MM-DD)

Attached the screenshot of the error

 ![image](https://forum.electroneek.com/uploads/default/original/1X/e18d52749a19b645352613e4bc6563b282113fa9.png)

Kindly let me know how to fix this issue.

Thanks

---

<div class="post-metadata">

**Author:** ![d.motta](https://forum.electroneek.com/user_avatar/forum.electroneek.com/d.motta/32/333_2.png) [@d.motta](https://forum.electroneek.com/u/d.motta)\
**Post date:** [December 22, 2022, 1:39am UTC](https://forum.electroneek.com/t/getting-error-while-calculating-differences-between-dates/1785/2 "2022-12-22T01:39:18Z")

</div>

Hi @achyu!  
You need to read data from Excel document by using “Read Excel Cell” activity and then change the format for every row.

 ![image](https://forum.electroneek.com/uploads/default/original/1X/24e57569e559541c7360d6b9688797feb22df278.png)  
You can also use a loop to process the data for each row where` i` variable is a value of the row:  
 ![image](https://forum.electroneek.com/uploads/default/original/1X/ec96d50f0999b6f67fb01448af17a0daa14c9ca7.png)

---

<div class="post-metadata">

**Author:** ![Zohari](https://forum.electroneek.com/user_avatar/forum.electroneek.com/zohari/32/515_2.png) [@Zohari](https://forum.electroneek.com/u/Zohari)\
**Post date:** [March 17, 2023, 4:01pm UTC](https://forum.electroneek.com/t/getting-error-while-calculating-differences-between-dates/1785/4 "2023-03-17T16:01:14Z")

</div>

Hi @achyu here is how you can calculate the date difference.

To calculate the date difference:

1. Set two variables with a valid date format
2. Add the [Calculate difference](https://help.electroneek.com/hc/en-us/articles/360020188898-Calculate-difference) activity
3. Set the “Initial date” parameter using the variable name set in step 1 or use the “Set a value” picker
4. Set the date to subtract the parameter using the variable name set in step 1 or use the “Set a value” picker
5. Save the result using the [Assign value to variable](https://help.electroneek.com/hc/en-us/articles/360019151257-Assign-value-to-variable) activity (added by default)

**Note** : Studio Pro also supports date management using the [Moment Js](https://momentjs.com/docs/) library.

Example:

`1moment().format('MMMM Do YYYY, h:mm:ss a'); // December 19th 2022, 7:47:27 pm 2moment().format('dddd'); // Monday 3moment().format("MMM Do YY"); // Dec 19th 22 4moment().format('YYYY [escaped] YYYY'); // 2022 escaped 2022 5moment().format();`

Bear in mind that the **MomentJs library methods** must be used in the “Calculate a value” parameter of the [Assign value to variable](https://help.electroneek.com/hc/en-us/articles/360019151257-Assign-value-to-variable) activity.
