Python script in dynamo for finding difference in days and dates with units

hello guys, i need some help. I need to find difference of durations in the planned and scheduled durations.

but these are not in numbers, it has units (Days) with it, its not possible to get them in numbers.

Ive imported the planned and scheduled in durations in the dynamo python node, i need a script where it can calculate the difference between the days without bothering the units.

Need to do the similar thing with the scheduled and planned start and finish dates. please help

1 Like

you can always convert to seconds, find difference and convert back to hours (dividing by 3600) and so on.

1 Like

sorry i dint get your idea, actually i can find the difference in days as well, but the thing is i have “days” written with it, i want to extract only the numbers out of these input.

@uaftab.cem19 ,


An alternative method:

import re

strings = IN[0]
integers = []
for string in strings:
	integers.append(re.findall("\d+", string)[0])

OUT = integers

This method is for a list of strings.