We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Help calculating during

Oumag
6 - Meteoroid

Hello,

I want to calculate a duration between two dates for a specific population. I wrote this formula but the result but I can't find the desired result.

 

if [type_de_contrat]="Contractuel"
then DateTimeDiff([date_de_debut_contrat],[date_de_fin_prev_contrat],"MONTHS")
else 0
endif

 

Thanx for your help. 

 

8 REPLIES 8
binuacs
21 - Polaris

@Oumag your formula seems to be correct. please check the datatypes of the date fields are DateTime/Date type. 

Jonny
11 - Bolide

Hi Oumag. I Tried your formula with some sample dates I have and The formula is fine and I get a result, see below:

Jonny_0-1649415625083.png

 

it would help if you could share a sample of your workflow and maybe specify what is the result you are looking for?

PhilipMannering
16 - Nebula
16 - Nebula

You probably want to switch [date_de_debut_contrat] and [date_de_fin_prev_contrat]. 

 

If you provide some sample data with expected output, then I'm sure @binuacs can solve it! :)

Oumag
6 - Meteoroid

thanx for your help :

Oumag_0-1649416126614.png

 

Oumag_1-1649416191320.png

 

PhilipMannering
16 - Nebula
16 - Nebula

A sample of your data would help here, but you need to parse your dates first.

 

You can create a new field in a Formula Tool with the expression,

datetimeparse([my_date_field_as_a_string], '%d/%m/%Y')

 

Also, your years are "0001"?

Oumag
6 - Meteoroid

Please find an extract of my dataset. 

binuacs
21 - Polaris

@Oumag There are some invalid dates like 01/01/01 will become NULL when you convert it into Alteryx DateTime

 

binuacs_0-1649423316001.png

 

 

 

Oumag
6 - Meteoroid

Thanx a lot for your help, @binuacs your solution is OK !!! 

Labels
Top Solution Authors