# Changing a variable during automation

**URL:** <https://forums.toadworld.com/t/changing-a-variable-during-automation/7235>\
**Category:** Toad Data Point & Toad Intelligence Central\
**Created:** [April 25, 2012, 3:55pm UTC](https://forums.toadworld.com/t/changing-a-variable-during-automation/7235 "2012-04-25T15:55:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![planomax](https://avatars.discourse-cdn.com/v4/letter/p/91b2a8/32.png) [@planomax](https://forums.toadworld.com/u/planomax)\
**Post date:** [April 25, 2012, 3:55pm UTC](https://forums.toadworld.com/t/changing-a-variable-during-automation/7235/1 "2012-04-25T15:55:49Z")

</div>

I have a query that uses TDA’s date variables such as ‘calendar\_\_gregorian\_\_current\_\_month\_\_’ . I’d like to be able to switch that to ‘calendar\_\_gregorian\_\_previous\_\_month\_\_’ based on a query/variable earlier in the automation script. Is that possible?

---

<div class="post-metadata">

**Author:** ![Debbie\_Peabody](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/debbie_peabody/32/18_2.png) [@Debbie\_Peabody](https://forums.toadworld.com/u/Debbie_Peabody)\
**Post date:** [April 25, 2012, 4:36pm UTC](https://forums.toadworld.com/t/changing-a-variable-during-automation/7235/2 "2012-04-25T16:36:03Z")

</div>

Yes you can do this. I would use the find and replace feature.

Have your SQL in a script with some token that you can always find.

IE:

Select \* from table where mydate = THIS\_IS\_TOKEN;

Based on your If statement, find and replace “THIS\_IS\_TOKEN” with '‘calendar\_\_gregorian\_\_current\_\_month\_\_’" or ''calendar\_\_gregorian\_\_previous\_\_month\_\_" and save to new file.

Use that new file in your execute activity.

Debbie

---

<div class="post-metadata">

**Author:** ![planomax](https://avatars.discourse-cdn.com/v4/letter/p/91b2a8/32.png) [@planomax](https://forums.toadworld.com/u/planomax)\
**Post date:** [April 30, 2012, 10:54am UTC](https://forums.toadworld.com/t/changing-a-variable-during-automation/7235/3 "2012-04-30T10:54:24Z")

</div>

Thank you!!!
