# Weekly Average Calculation on Timeseries Chart

**URL:** <https://forum.inductiveautomation.com/t/weekly-average-calculation-on-timeseries-chart/68569>\
**Category:** Ignition\
**Created:** [January 13, 2023, 12:46pm UTC](https://forum.inductiveautomation.com/t/weekly-average-calculation-on-timeseries-chart/68569 "2023-01-13T12:46:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Divya\_Chorge1](https://avatars.discourse-cdn.com/v4/letter/d/e19b73/32.png) [@Divya\_Chorge1](https://forum.inductiveautomation.com/u/Divya_Chorge1)\
**Post date:** [January 13, 2023, 12:46pm UTC](https://forum.inductiveautomation.com/t/weekly-average-calculation-on-timeseries-chart/68569/1 "2023-01-13T12:46:29Z")

</div>

Hi,  
I wanted to calculate the weekly average data from a dataset tag and show the average data on timeseries chart. How can I calculate the weekly average data.  
I cannot use the format of system.date.weeksBetween(first, second) because I have taken StartDate and EndDate as a string format and string format is not supported in system.date.weeksBetween.  
What can I do alternatively Please Suggest.

---

<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:** [January 13, 2023, 12:49pm UTC](https://forum.inductiveautomation.com/t/weekly-average-calculation-on-timeseries-chart/68569/2 "2023-01-13T12:49:24Z")

</div>

Don't use string formats for dates and times and timestamps. That prevents all of Ignition's tools from properly handling time zones and locales. (Or allowing the user to customize same.)

Dates and times should only be converted to strings at the point of display. They should only be parsed from strings when the string is keyed in by a user.

Yes, really.

---

<div class="post-metadata">

**Author:** ![Divya\_Chorge1](https://avatars.discourse-cdn.com/v4/letter/d/e19b73/32.png) [@Divya\_Chorge1](https://forum.inductiveautomation.com/u/Divya_Chorge1)\
**Post date:** [January 13, 2023, 1:08pm UTC](https://forum.inductiveautomation.com/t/weekly-average-calculation-on-timeseries-chart/68569/3 "2023-01-13T13:08:44Z")

</div>

Thanks will do the same I will use date format only.  
Is there any way to calculate weekly average data and show weekly date and the corresponding value to that date.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [January 13, 2023, 2:12pm UTC](https://forum.inductiveautomation.com/t/weekly-average-calculation-on-timeseries-chart/68569/4 "2023-01-13T14:12:20Z")

</div>

How is the tag history stored?

---

<div class="post-metadata">

**Author:** ![Divya\_Chorge1](https://avatars.discourse-cdn.com/v4/letter/d/e19b73/32.png) [@Divya\_Chorge1](https://forum.inductiveautomation.com/u/Divya_Chorge1)\
**Post date:** [January 13, 2023, 3:39pm UTC](https://forum.inductiveautomation.com/t/weekly-average-calculation-on-timeseries-chart/68569/5 "2023-01-13T15:39:16Z")

</div>

In memory tag I am writing the data it is not a historical tag.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [January 13, 2023, 3:51pm UTC](https://forum.inductiveautomation.com/t/weekly-average-calculation-on-timeseries-chart/68569/6 "2023-01-13T15:51:43Z")

</div>

> [@Divya\_Chorge1](#):
>
> from a dataset tag and show the average data on timeseries chart.

Sorry, missed the dataset part.  
Will need to know how your dataset is organized.
