Extract part of date or time with %subdt

How to extract the current Year and Month:

Define date field:

D  ISOdate      S              D   datfmt(*ISO) inz(*SYS) 

If not initializing ISOdate to current system date (*SYS) in the D spec it is easy to get the system date:

            eval ISOdate  = %date()

Then select what part of the date you need with %subdt:
  
            eval curYear  = %subdt(ISOdate: *YEARS)
            eval curMonth = %subdt(ISOdate: *MONTHS)

How to retrieve the date one month prior to today:

            eval ISOdate = %date()
            eval ISOdate = %date() - %months(1)

How to extract current minutes from time or timestamp as a character value:

/free
  curMinute = %char(%subdt(%time():*MN));
/end-free

Valid parameters:

*Days, *D, *Months, *M, *Years, *Y, *Seconds, *S, *Minutes, *MN, *Hours, *H (and *MSeconds, *MS for timestamps).