# Increment a date variable?

**URL:** <https://www.finalbuilder.com/forums/t/increment-a-date-variable/4574>\
**Category:** Discussion\
**Created:** [July 11, 2014, 6:46am UTC](https://www.finalbuilder.com/forums/t/increment-a-date-variable/4574 "2014-07-11T06:46:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonathanmeltzer](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jonathanmeltzer](https://www.finalbuilder.com/forums/u/jonathanmeltzer)\
**Post date:** [July 11, 2014, 6:46am UTC](https://www.finalbuilder.com/forums/t/increment-a-date-variable/4574/1 "2014-07-11T06:46:15Z")

</div>

Greetings! &nbsp;In my action list, I set a %nowDate% variable to (today - 1 month) using a GetDateTime action. &nbsp;I have a While Loop set up to do a series of actions until %nowDate% is equal to today. &nbsp;At the end of the While Loop, I want to increment %nowDate% by 1 day. &nbsp;I cannot figure out a way to do that. &nbsp;Set Variable only allows integer increments, and does not allow me to increment a date that way.  
  
If I set %nowDate% to be a Variant instead of a DateTime variable, would that work? &nbsp;If not, is there a way to increment a DateTime variable by a day (or any other time period)?  
  
Thanks,  
  
Jonathan

---

<div class="post-metadata">

**Author:** ![nevar](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/n/c4cdca/32.png) [@nevar](https://www.finalbuilder.com/forums/u/nevar)\
**Post date:** [July 14, 2014, 12:46pm UTC](https://www.finalbuilder.com/forums/t/increment-a-date-variable/4574/2 "2014-07-14T12:46:30Z")

</div>

Hi Jonathan,   
  
 If you know that %nowDate% should be today after the while loop, and you require the %nowDate% to have “today + 1 day”. I would simply suggest setting the variable again through the GetDateTime action.   
  
 This would really only work if after the while loop %nowDate% is today after the while loop though. I assume that’s the test in the while loop.   
  
 To do the above without having a difference in time, create a variable %todayMinusOne% which is set directly after %nowDate% is initialised. Then use the SetVariable to assign %todayMinusOne% to %nowDate%. Otherwise you will get a difference in the datetimes of how long it took to run the while loop.   
  
 Let us know how that goes for you.

---

<div class="post-metadata">

**Author:** ![jonathanmeltzer](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jonathanmeltzer](https://www.finalbuilder.com/forums/u/jonathanmeltzer)\
**Post date:** [July 14, 2014, 5:58am UTC](https://www.finalbuilder.com/forums/t/increment-a-date-variable/4574/3 "2014-07-14T05:58:55Z")

</div>

That does not work the second time through the loop…the issue is that the start date is variable, and the end date is the current date. The solution I found was to use a For loop with the start date and end date, incrementing by 1. That works like a charm.

---

<div class="post-metadata">

**Author:** ![nevar](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/n/c4cdca/32.png) [@nevar](https://www.finalbuilder.com/forums/u/nevar)\
**Post date:** [July 17, 2014, 5:58am UTC](https://www.finalbuilder.com/forums/t/increment-a-date-variable/4574/4 "2014-07-17T05:58:05Z")

</div>

Great to hear that worked out for you in the end.
