I’m trying to write a script that does something if the current date is before (or after) some specified date.
If there’s a way to compare dates in RouterOS scripting language without resorting to table lookups and string/numeric conversions, I’m not seeing it.
The scripting guide says that the data type “time” is a “date and time value,” but I’m pretty sure that’s not accurate. I can’t get it to work with dates at all.
[admin@Shop.RH.GABB] /system clock> :put [:totime “aug/1/2018”]
[admin@Shop.RH.GABB] /system clock> :put [:tonum [:totime “aug/1/2018”]]
[admin@Shop.RH.GABB] /system clock> :put [:tonum [:totime “aug/01/2018”]]
[admin@Shop.RH.GABB] /system clock> :put [:typeof “aug/01/2018”]
str
[admin@Shop.RH.GABB] /system clock> :put [:typeof aug/01/2018]
str
[admin@Shop.RH.GABB] /system clock> :put [:typeof [:totime “aug/01/2018”]]
nil
[admin@Shop.RH.GABB] /system clock> :put [:typeof [:totime “aug/01/2018 00:00:00”]]
nil
[admin@Shop.RH.GABB] /system clock> :put [/system clock get time]
13:25:57
[admin@Shop.RH.GABB] /system clock> :put [:typeof [/system clock get time]]
time
[admin@Shop.RH.GABB] /system clock> :put [:typeof [/system clock get date]]
str
[admin@Shop.RH.GABB] /system clock> :put [:typeof “13:00:00”]
str
[admin@Shop.RH.GABB] /system clock> :put [:typeof [:totime “aug/1/2018 13:00:00”]]
nil
[admin@Shop.RH.GABB] /system clock> :put [:typeof [:totime “aug/1/2018,13:00:00”]]
nil
[admin@Shop.RH.GABB] /system clock> :put [:typeof [:totime “aug/1/2018:13:00:00”]]
nil
[admin@Shop.RH.GABB] /system clock> :put [:typeof [:totime “4d13:00:00”]]
time
Am I missing something, or does the language just not handle dates without writing code to do them by hand?