Rule with actual date

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

Hi @lale

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

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…

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

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

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 :smiley: