Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.

How do i use DateTimeDiff Formula for


i want to use DateTimeDiff Formula for: In case of Department Type = HR and Request submitted date XXX and Approved Date XXXX < 15 Days OR Department Type = MKT and Request submitted date XXX and Approved Date XXXX < 17 Days then Late request Else Normal request


Thanks in Advance.

I think you want something like:



IF ([Department Type] = "HR" AND DateTimeDiff([Approved Date XXXX], [Request submitted date XXX], "days") > 15) 
OR ([Department Type] = "MKT" AND DateTimeDiff([Approved Date XXXX], [Request submitted date XXX], "days") > 17)


The Dates need to be in Alteryx Date or DateTime format (i.e. yyyy-MM-dd or yyyy-MM-dd HH:mm:ss).

DateTimeDiff takes end date first and start date date second. 

You can specify different units like days as the third argument.


Hopefully enough to get you going



Thanks for your respond, i tried to replicate the same provided formula but the attached screenshot error displayed despite all dates values are in Date format. 



Could you post the data?


It is trying to convert the value 'Normal' into a date


Here you are.

Alteryx Certified Partner
Alteryx Certified Partner

@Mostafa_Anwar your formula tool 68 has the following logic...


IF ([Venue Type] = 'Inside HCO' AND DateTimeDiff([EventDate], [SubmittedDate], "days")>=14)
OR ([Venue Type] = 'Outside HCO' AND DateTimeDiff([EventDate], [SubmittedDate], "days")>=30) then 'Late Submisstion' Else 'Normal' endif

Which returns one of two strings, 'Late Submission' or 'Normal', these are string in type, but you have the DateType as 'Date', you need to convert this to a string type.


Remember, when creating a field you are specifying the datetype of the result, not the component fields that are being used.




Thanks Ben for your respond, Is it possible to change this in my previous dataset shared? because i tired to change it to String but in vain. 

Just amend the type in the Formula editor:



Hopefully should fix it. Tweaked version attached.


Thanks Its worked now :)

Truly appreciated.