Community discussions

MikroTik App
 
eldoncito2019
Member
Member
Topic Author
Posts: 333
Joined: Fri Jun 14, 2019 1:07 pm

UNDERSTANDING SCRIPT

Mon May 09, 2022 6:58 pm

How do I make this script
:global currentdate
{
:local newdate "06-05-2022"
:if ($newdate => $currentdate) do= {:put "the new date is minor"} else={:put "the new date is major"}
:delay 2
set currentdate $newdate
}
write if the new date is minor than the current date "the new date is minor" and if the new date is major write "the new date is major". Thank you.

EL DONCITO.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: UNDERSTANDING SCRIPT

Mon May 09, 2022 8:00 pm

You can not compare strings on RouterOS if are more, or if are less, or if are equal or less, (or if are equal or major).
You can check only if are equal or not equal (different)
But for some reason => do not give an error but have exactly the same function as "="

You need to compare the dates when both are converted to Unix Epoch,
or write a multiple nested function than first compare year, then month, then day.

On your case, first check if are equal, then on another :if ckec if are major or equal...

Who is online

Users browsing this forum: No registered users and 19 guests