substring only the year or month from current date

Answers

USER>Write $Piece($ZDate($Horolog,9)," ")
January
USER>Write $Piece($ZDate($Horolog,3),"-")
2018

You can use DATEPART function:

w $SYSTEM.SQL.DATEPART("year", $h)
>2018
w $SYSTEM.SQL.DATEPART("month", $h)
>1

The advantage of this approach is more readable code.