Weekly Average Calculation on Timeseries Chart

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.

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.

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.

How is the tag history stored?

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

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