setvar tag support 'expr' attr 

example
<cml:setvar name='dtstr'
expr='strftime("%Y%m%d",localtime(env(dtkey)))'/>