Alteryx Designer Desktop Discussions

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

How to find difference between time in seconds

AshokBhatt
7 - Meteor

Hi,

I tried to find difference between time in seconds but unable to. Could you please suggest what should be the best way to find difference.

I was using DateTimeDiff() function.

 

Regards,

18 REPLIES 18
chris_love
12 - Quasar
You are correct: DateTimeDiff (, , )
eg.

datetimediff([StartTime],[EndTime],"seconds")
AshokBhatt
7 - Meteor

I was using the same but getting Null() values. I tried to get output values using Int, float fields nowhere getting the results. Attaching sample workflow, I might be missing something. Kindly support.

 

chris_love
12 - Quasar

Oops looks like I replied to a new thread (perhaps @TaraM can merge?)

 

Anyway I think you can't do this on Time variables, just datetime. So I used DateTimeToday() to add a date and converted them. See attached. Slightly more tools than you'd want but it works.

 

Chris

AshokBhatt
7 - Meteor

Sorry, I didn't understand the solution.

 

You mean to say that If we add DateTimeToday() as prefix for Start and End time, DateTimeDiff(,,) should work. 

And, if the date changes, does the same logic work? e.g. Start time is 23:50:00 hrs and End time is 00:40:00.

 

Could you please share modified workflow.

Need your support on this.

chris_love
12 - Quasar

You only had times in your workflow, therefore I added todays date (it oculd have been any date) to turn it into a datetime. Did you see my module attachment at the bottom of my last post?

 

In terms of whether the date changes then you could amend the logic to add 1 to the day if the end date is less than the start date, but can you not capute the date of the occurence and solve this properly, then Alteryx will handle it.

 

in summary Alteryx requires a date and a time to calculate a difference.

 

Hope that is clearer.

 

 

AshokBhatt
7 - Meteor

Thanks Chris,

But last attachement seems to have no DateTimeToday() function used.  Might be I am missing something.

Anyway, thanks for support.

 

- AB

chris_love
12 - Quasar

Blast, sorry. There's an issue with exporting packages where if you don't save them first you package the saved version. Try this version, my apologies.

 

 

AshokBhatt
7 - Meteor

:) Wonderful.

 

Thank you very much for this.

 

chris_love
12 - Quasar

No problem, glad we got there in the end!

Labels