Best answer

Create multiple date variables in a single step

  • 12 May 2021
  • 3 replies
  • 292 views

Userlevel 1

Not sure how to phrase this, so I’ll describe the scenario:

  • I have a scheduled Zap, running weekly
  • there’s no external input data involved
  • I use the {{zap_meta_utc_iso}} global variable as a starting date
  • A later step is supposed to send future timestamps, counted from this starting point (today +1d, today +2d etc)
  • e.g. today is
  • 2021-05-12T11:34:10+02:00
    and I need multiple items/ variables I can use in later Actions, e.g.
    day1: 2021-05-12T11:34:10+02:00
    day2: 2021-05-13T11:34:10+02:00
    day3: 2021-05-14T11:34:10+02:00
    day4: 2021-05-15T11:34:10+02:00
    day5: 2021-05-16T11:34:10+02:00
    day6: 2021-05-17T11:34:10+02:00
    day7: 2021-05-18T11:34:10+02:00

What I *could* do is using individual “Formatter” steps, each using a “Add/Subtract time” action with a “{{iso}} +1d”, “{{iso}} +2d” etc. notation ad nauseam.

But this look ridiculously inefficient, and I bet there’s easier solutions out there (don’t let me down, Internet People!) Any ideas? I’ll take line items, custom code, pretty much any kind of unorthodox (but elegant) solution.

Thanks!

icon

Best answer by GetUWired 14 May 2021, 15:09

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

Userlevel 7
Badge +14

Hi @Shazap!

You can use a Code step to create multiple variables: https://zapier.com/apps/code/help

Userlevel 7
Badge +12

HI @Shazap! 

I would use the advanced utilites action referenced here: 

 
The run javascript code step supports moment.js library which would be helpful. The share link is here: https://zapier.com/developer/public-invite/112461/039174f595539444ce5c14e114c1dc1e/ 

After clicking the link. Search for Advanced Utilities in your zap builder then choose run javascript.

The code for which looks something like this: 

let today = moment(inputData.today);
let plusOne = moment(today).add(1,'day');
let plusTwo = moment(today).add(2,'day');

return {
today: today,
plus_one_day: plusOne,
plus_two_day: plusTwo
}

For brevity, i’ve only shown adding the one and two days but the code can easily be repeated.

Happy Zapping!

Tim @ GetuWired

Userlevel 1

You’re a saint! This is exactly what I needed - much appreciated!