Add leading zeros

Hi.

I’m trying to add a custom quote number which should be a combination of a text, the year, the month and an incremental number in a 4 digit format.

Example:

AG-1708-0034

After a lot of research I got the first part (AG-1708-) figured out. I use a workflow to fill my newly created field via a calculated field with the following formula:
AG-{now(ym)}-

That works great but now I am struggling with the last part for which I want to use the number field of the database but change it’s format so it will always show 4 digits. The missing digits should be replaced by zeros.

I found the function “str_pad” but it doesn’t seem to work.

Can somebody help me with that?

Regards,

Bob