Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Generate Dates + & - 2 days

jwessma
7 - Meteor

Hello, I am trying to take a date and generate new rows that bring that date 2 days backward and 2 days forward and I'm having a tough time figuring out how to get it all to appear in one column. Any ideas?

 

Example of what I want to do:

 

Existing Data:

 

Record IDDate
17/1/2017
26/4/2017

 

Turned into:

 

Record IDDate
17/1/2017
16/30/2017
16/29/2017
17/2/2017
17/3/2017
26/4/2017
26/3/2017
26/2/2017
26/5/2017
26/6/2017
2 REPLIES 2
NicoleJohnson
ACE Emeritus
ACE Emeritus

Part of the solution might just be in the first word of your title! The Generate Rows tool should do the trick.

 

1.Convert your Date column to DateTime format (yyyy-mm-dd) using either the DateTime tool or a formula.

2. Calculate the Start Date using a formula tool: DateTimeAdd([Date],-2,"days")

3. Use the Generate Rows tool to add a new row for every date between the start date and the end date (which will be the original date + 2 days, again using a DateTimeAdd formula)

 

See attached for an example workflow, and let me know if this accomplishes what you were trying to achieve!

 

Cheers,

NJ

jwessma
7 - Meteor

Thanks for your response!

Labels