# system.date.addWeeks Variable Question

**URL:** <https://forum.inductiveautomation.com/t/system-date-addweeks-variable-question/92334>\
**Category:** Ignition\
**Tags:** ignition79, scripting\
**Created:** [June 25, 2024, 2:14pm UTC](https://forum.inductiveautomation.com/t/system-date-addweeks-variable-question/92334 "2024-06-25T14:14:59Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kyle\_Metz](https://avatars.discourse-cdn.com/v4/letter/k/8edcca/32.png) [@Kyle\_Metz](https://forum.inductiveautomation.com/u/Kyle_Metz)\
**Post date:** [June 25, 2024, 2:14pm UTC](https://forum.inductiveautomation.com/t/system-date-addweeks-variable-question/92334/1 "2024-06-25T14:14:59Z")

</div>

Im making a pm scheduler using the following script:

\<today = system.date.now()  
WeeksFromToday = system.date.addWeeks(today, 2)  
system.tag.write("PM/DateCalc", WeeksFromToday)\>

If I put a tag in for the "2" to make the week counter variable it gives me a:  
Traceback (most recent call last):

File "event:actionPerformed", line 2, in

TypeError: addWeeks(): 2nd arg can't be coerced to int

Ignition v7.9.1 (b2017012511)  
Java: Oracle Corporation 1.8.0\_411

The variable im trying to use is an INT4

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 25, 2024, 2:17pm UTC](https://forum.inductiveautomation.com/t/system-date-addweeks-variable-question/92334/2 "2024-06-25T14:17:46Z")

</div>

Are you reading the tag or just putting in a tag path? You will need to read the tag.

Something like this:

```python
today = system.date.now()
weeks = system.tag.readBlocking(["week_tag_to_use"])[0].value
WeeksFromToday = system.date.addWeeks(today, weeks)
system.tag.write("PM/DateCalc", WeeksFromToday)

```

---

<div class="post-metadata">

**Author:** ![Kyle\_Metz](https://avatars.discourse-cdn.com/v4/letter/k/8edcca/32.png) [@Kyle\_Metz](https://forum.inductiveautomation.com/u/Kyle_Metz)\
**Post date:** [June 25, 2024, 2:34pm UTC](https://forum.inductiveautomation.com/t/system-date-addweeks-variable-question/92334/3 "2024-06-25T14:34:39Z")

</div>

Thanks for the reply, are reading blocks just for strings or lists.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [June 25, 2024, 2:38pm UTC](https://forum.inductiveautomation.com/t/system-date-addweeks-variable-question/92334/4 "2024-06-25T14:38:54Z")

</div>

Block means it blocks the gui thread until the operation is complete, and it returns a list of values because it accepts multiple tag paths at a time.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 25, 2024, 2:39pm UTC](https://forum.inductiveautomation.com/t/system-date-addweeks-variable-question/92334/5 "2024-06-25T14:39:57Z")

</div>

It's not reading blocks, but blocking the thread while reading.

See the manual: [https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-tag/system-tag-readBlocking](https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-tag/system-tag-readBlocking)

---

<div class="post-metadata">

**Author:** ![Kyle\_Metz](https://avatars.discourse-cdn.com/v4/letter/k/8edcca/32.png) [@Kyle\_Metz](https://forum.inductiveautomation.com/u/Kyle_Metz)\
**Post date:** [June 25, 2024, 2:52pm UTC](https://forum.inductiveautomation.com/t/system-date-addweeks-variable-question/92334/6 "2024-06-25T14:52:59Z")

</div>

Im still on 7.9, I tired the read function but it returns the same error.

---

<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:** [June 25, 2024, 2:56pm UTC](https://forum.inductiveautomation.com/t/system-date-addweeks-variable-question/92334/7 "2024-06-25T14:56:36Z")

</div>

> [@Kyle\_Metz](#):
>
> Im still on 7.9

In the future, you should mark the post with that tag. I'm taking care of it for you. This post also belongs in the Ignition category, not general discussion.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 25, 2024, 2:58pm UTC](https://forum.inductiveautomation.com/t/system-date-addweeks-variable-question/92334/8 "2024-06-25T14:58:01Z")

</div>

> [@Kyle\_Metz](#):
>
> Im still on 7.9, I tired the read function but it returns the same error.

In that case:

```python
today = system.date.now()
weeks = system.tag.read("week_tag_to_use").value
WeeksFromToday = system.date.addWeeks(today, weeks)
system.tag.write("PM/DateCalc", WeeksFromToday)

```

---

<div class="post-metadata">

**Author:** ![Kyle\_Metz](https://avatars.discourse-cdn.com/v4/letter/k/8edcca/32.png) [@Kyle\_Metz](https://forum.inductiveautomation.com/u/Kyle_Metz)\
**Post date:** [June 25, 2024, 3:03pm UTC](https://forum.inductiveautomation.com/t/system-date-addweeks-variable-question/92334/9 "2024-06-25T15:03:18Z")

</div>

You're awesome, it was the .value I was missing.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 25, 2024, 3:05pm UTC](https://forum.inductiveautomation.com/t/system-date-addweeks-variable-question/92334/10 "2024-06-25T15:05:37Z")

</div>

No sweat.

For 7.9 the manual on this is here: [system.tag.read | Ignition User Manual](https://docs.inductiveautomation.com/docs/7.9/appendix/scripting-functions/system-tag/system-tag-read)

A tag read will return a QualifiedValue:

QualifiedValue - A qualified value. This object has three sub-members: value, quality, and timestamp.
