The Alteryx Community is a finalist in three 2026 CMX Awards! Help us win Customer Support Community, Most Engaged Community, and User Group Program of the Year - vote now! (it only takes about 2 minutes) before January 9.
ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
解決済み

Calculating time difference in HH:MM:SS but getting error messages

Emmm
メテオール

Hi there! Can someone please help me take a look at the workflow what went wrong and how to fix it? 

 

screenshot.png

8件の返信8
davidskaife
マグネター

Hi @Emmm 

 

Try tweaking the formula to this: 

TOSTRING(FLOOR([TimeDiffSeconds] / 3600)) + ":" +
RIGHT("0" + TOSTRING(FLOOR(([TimeDiffSeconds] / 3600) / 60)), 2) + ":" +
RIGHT("0" + TOSTRING([TimeDiffSeconds] / 60), 2)

All i did was wrap the first Floor calc in TOSTRING, and you were using % instead of / for the other two calculations

Emmm
メテオール

Thanks @davidskaife 

but in this way, if I use / instead of %, the results were wrong as you can see in the screenshot below. It's not calculating the interval properly...

 

image.png

davidskaife
マグネター

Hi @Emmm 

 

Just noticed that the final output wasn't working; thanks to the solutions posted here -> https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/Calculate-time-hours-minutes-s... see below for a much cleaner formula

 

RIGHT(DateTimeAdd("1900-01-01",[TimeDiffSeconds],"seconds"),8)
Emmm
メテオール

Thank you so much! @davidskaife 

 

Now i'm really close - for cases like these crossing dates interval, do you know how can i get the right interval? 

 

update.png

Raj
ネビュラ

@Emmm 
find the workflow attached is this the result you are looking for?


mark the solutions attached if solved.

CoG
マグネター

It seems that a mathematical error has been propagating through various responses. The only error in the OP's formula was the use of the '%' to perform modulus. You need to use the MOD() function to perform the appropriate calculation.

 

TOSTRING(FLOOR([TimeDiffSeconds] / 3600)) + ":" +
RIGHT("0" + TOSTRING(FLOOR(MOD([TimeDiffSeconds], 3600) / 60)), 2) + ":" +
RIGHT("0" + TOSTRING(MOD([TimeDiffSeconds], 60)), 2)

 

Happy Solving!

cjaneczko
パルサー

Another formula to try.

 

PadLeft(ToString(Floor([TimeDiffSeconds]/3600)),2,"0") +
Right(DateTimeAdd("1900-01-01",[TimeDiffSeconds],"seconds"),6)
Emmm
メテオール

Thanks everyone!!!! 

ラベル
トップのソリューション投稿者