Scripts using dates broken

I’ve read a couple of other threads, but I’m having a hard time understanding the easiest (yet best) way to implement getting the date into a filename in a script.

Seems this doesn’t work with 7.10+:

/system clock get date

Is there an easy way to assign a variable the current date?

Thanks.

This is what I have come up with so far. I think it works.


:local year [:pick [/system clock get date] 0 4]
:local month  [:pick [/system clock get date] 5 7]
:local day [:pick [/system clock get date] 8 10]
:local identitydate "$[/system identity get name]_$year_$month_$day"
/export show-sensitive file="$identitydate"

only one call should be made, not 3…
There is a chance you get a different day or month between calls.…

/system
:local cdate [clock get date] 
:local yyyy  [:pick $cdate 0  4]
:local MM    [:pick $cdate 5  7]
:local dd    [:pick $cdate 8 10]
:local identitydate "$[identity get name]_$yyyy-$MM-$dd"
/export show-sensitive file="$identitydate"

Thank you for this advice.

And thank you for your other post, from which I learned the “:pick # #” technique!