Javascript for loop using date as counter
Hi. I'm trying to create a for loop using a date starting with 1/1/2021 and going to today's date as below:
for(var d = aqDateTime.SetDateElements(2021, 01, 01); d <= aqDateTime.Now(); aqDateTime.AddDays(d, 1))
{
...
}
The var d is not incrementing by 1 day each time. It's staying constant at 01/01/2021. Can someone point me in the right direction? I had it working when I was using a javascript date object, but that creating other hurdles inside the for loop. I really want to use a DateTime (or Date) in TestComplete's native date format. Thanks!
Hi,
> It's staying constant at 01/01/2021.
It stays constant because you do not change it.
Try this:
for(var d = aqDateTime.SetDateElements(2021, 01, 01); d <= aqDateTime.Now(); d = aqDateTime.AddDays(d, 1))