lale
February 15, 2020, 3:05pm
1
Hello!
I’m asking if it’s possible to add rule in respect to the actual date.
I want to check and filter dates with the actual date of today. I can’t find something.
ICan someone help me?
For example i want to check the warranty end with the actual date. Is the warranty end reached or if there i any time left.
Regards
Lale
Kulkul
February 15, 2020, 4:37pm
2
Hi @lale
lale:
someone help me?
Welcome to Dynamo Forum!
Could you please be more specific. Possible to drop your data structure or relevant files?
2 Likes
DateTime.Now amd DateTime.Today nodes outputs the current time and date
They are in Input->DateTime
1 Like
lale
February 16, 2020, 8:39am
4
I get all elements of “Brandmelder” and the parameter “Garantieende” (warranty end). Then i try to check if there is time life left.
Maybe i have to change the format of my parameter…
lale
February 16, 2020, 9:04am
5
i’ve changed the format but at the end i want to know if the actual date is later or earlier then the warranty end.
Does someone know it?
thanks in advance!
Use timespan.bydatedifference instead simply a greater than operator:
Convert to some number and than you can compare the elements.
1 Like
If I remember correctly you can compare DateTime objects directly in python using standard operators like > or < …
1 Like
Kulkul
February 16, 2020, 5:09pm
8
Hi @lale
As @Andreas_Dieckmann pointed, you can do this way in python:
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
import datetime
def task(Rule_With_Actual_Date):
dt = datetime.datetime.strptime(Rule_With_Actual_Date, "%d.%m.%Y") <= datetime.datetime.now()
return dt
OUT = map(task,IN[0])
3 Likes
And if you prefer to stick with nodes:
2 Likes
lale
February 18, 2020, 12:16pm
10
Thank you all. I’ve solved this problem with the timespan. Change it to minutes and compare which one is negative. Then i create to lists with the true and false ones.
It was easier than i thought