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

Datetimediff null values

jmathew94
7 - Meteor

Hello,

 

I am trying to find the difference between two timestamps using the Datetimediff function. I used substring to remove the AM/PM and EST from the timestamp however it is still not pulling in. I believe my issue is around the data type or formula for datetimediff? Please help

8 REPLIES 8
ShankerV
17 - Castor

Hi @jmathew94 

 

The date is not in the ISO format.

Please convert to YYYY-MM-DD format with the help of date time tool or using the same formula tool also.

binuacs
21 - Polaris

@jmathew94  you need to use the DateTimeParse function

 

Datetimediff(DateTimeParse([Approving Time Formula],’%d-%b-%Y),DateTimeParse([Input Time Formula],’%d-%b-%Y),’hours’)

ShankerV
17 - Castor

Hi @jmathew94 

 

A sample use case for your scenario.

 

ShankerV_0-1678976198615.png

 

Step 1: Input

ShankerV_1-1678976268810.png

 

Step 2: 

ShankerV_2-1678976286046.png

dd-Mon-yyyy hh:mm:ss

 

ShankerV_3-1678976303784.png

 

Step 3: 

 

ShankerV_4-1678976342525.png

ShankerV_5-1678976356381.png

 

Step 4:

 

ShankerV_6-1678976391641.png

DateTimeDiff([AT1],[IT1],"hours")

 

ShankerV_7-1678976401771.png

 

Many thanks

Shanker V

jmathew94
7 - Meteor

Great Thanks @ShankerV! This solution worked. One last question- if I am wanting to add minutes to the hours of completion how would i do so? For example, -1.23 hours or 5.32 hours

RobertOdera
13 - Pulsar

Hi, @jmathew94,@ShankerV , @binuacs 

 

Actually, it is a little more tricky than before answered.

 

Consider leveraging %d-Mon-%Y %I:%M:%S %p because AM/PM has implications in time duration

 

Check out the below and mark it as an acceptable solution if it works for you. Cheers!

 

RobertOdera_0-1678977961443.png

 

ShankerV
17 - Castor

Hi @jmathew94 

 

To Achieve the result in minutes also like 1.54 etc.

Tweak the formula in the tool.

 

ShankerV_0-1678983037264.png

(DateTimeDiff([AT1],[IT1],"minutes"))/60

 

ShankerV_1-1678983066382.png

 

Many thanks

Shanker V

jmathew94
7 - Meteor

Thanks this works however I am having trouble figuring out how to round this to the two decimals. Looks like some come through fine and some don't. 

ShankerV
17 - Castor

Hi @jmathew94 

 

The below change in the datatype will help to limit with 2 decimal places.

 

ShankerV_0-1679032255095.png

 

Many thanks

Shanker V

 

Labels
Top Solution Authors