I meant to answer this sometime back, but got busy.
The following general program mode template does what I think you want.
Code:
program:
date = field('#original_date');
# compute the components
year = subitems(date, 0, 1);
month = re(subitems(date, 1, 2), '^\D*$', '00');
day = ifempty(subitems(date, 2, 3), '00');
# compute the return value
strcat(year, '--', month, '--', day)
The trickiest part is the call to re. The pattern matches if the source contains only non-numeric characters, replacing them with '00' otherwise leaving them alone.