def Resultat(x,y): diff = x-y return '%d:%02d' % divmod(diff, 60) Variation = Resultat( !ScePUPbr! , !SitPUPbr!)
Solved! Go to Solution.
def Resultat(x,y): diff = x-y if diff < 0: sign = '-' else: sign = '' return sign+'%d:%02d' % divmod(abs(diff), 60)
diff = abs(x-y)
Take the absolute value of the difference:diff = abs(x-y)
def Resultat(x,y): diff = x-y if diff < 0: sign = '-' else: sign = '' #These are two single quotes (an empty string) return '%s%d:%02d' % (sign, divmod(diff, 60))
ERROR 000539: Error running expression: Resultat( -2000 , 0) <type 'exceptions.TypeError'>: %d format: a number is required, not tuple
def Resultat(x,y): diff = x-y if diff < 0: sign = '-' else: sign = '' #These are two single quotes (an empty string) return sign + '%d:%02d' % divmod(diff, 60)
def Resultat(x,y): diff = abs(x-y) #abs doesn't make any difference without a positive and negative value if diff < 0: sign = '-' else: sign = '' #These are two single quotes (an empty string) return sign + '%d:%02d' % divmod(diff, 60)