Alteryx Designer Desktop Discussions

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

Count days from dates

rafatomillero
7 - Meteor

I have:

 

[A]: 05/08/2023

[B]: 05/08/2022

 

and I want to output the number of days when subtracting [A] - [B], in this case 365. How do I achieve this?

4 REPLIES 4
DataNath
17 - Castor

Hey @rafatomillero, you can leverage the DateTimeDiff() function for this case. However, beforehand, you need your dates to be in a format that Alteryx can understand (YYYY-MM-DD), hence why you have to wrap each in the DateTimeParse() function. I've guessed that your current format is dd/mm/yyyy, but if it's mm/dd/yyyy, all you need to do is swap the %d and %m around.

 

DataNath_0-1664186037761.png

Emmanuel_G
13 - Pulsar

@rafatomillero 

 

Find attached the way of doing this.

 

Let me know if there is any issue and do not hesitate to mark this answer as solution if it helped.

 

Emmanuel_G_0-1664186026716.png

 

IraWatt
17 - Castor
17 - Castor

Hey @rafatomillero,

First thing to do is convert your text date to the Alteryx date format as currently your date is ambiguous it could be a US or UK date for instance. To do this I used the date time parse formula. Then your have two options:

 

Option one is to pivot your data onto one line using the Cross Tab Tool. This allows you to just use a normal row level formula:

IraWatt_0-1664186024748.png

Option two is to use a multi row formula to do calculations across multiple rows:

IraWatt_1-1664186113532.png

Here are some useful links for these topics: https://community.alteryx.com/t5/Learning-Paths/Getting-Started-Learning-Path/ta-p/475117#done

Multi Row Formula Tool https://community.alteryx.com/t5/Interactive-Lessons/Multi-Row-Formula/ta-p/82872

Date Functions: https://help.alteryx.com/20221/designer/datetime-functions

 

Any questions or issues please ask

Ira Watt
Technical Consultant
Watt@Bulien.com 

 

 

 

 

 

 

rafatomillero
7 - Meteor

Very helpful, thank @DataNath !

Labels