The clock scan command expects a list of one or two elements. The first element is the date and the second element is the time, if there. So an HL7 timestamp like 20090601164230 will not scan. You have to make it scanable.
Ther are a couple of different methods
set sdate “[string range $dt 0 7] [string range $dt 8 end]”
or
regsub — {(d{9})(.*)} $dt {1 2} sdate
Then: clock scan $sdate
As for math you can do all sorts of things like:
clock scan “2 days ago”. “last week” “-2 days”, etc.
For example using the above date:
clock format [clock scan $sdate]
=> Mon Jun 01 4:42:30 PM Central Daylight Time 2009
clock format [clock scan “2 days ago” -base [clock scan $sdate]]
=> Sat May 30 4:42:30 PM Central Daylight Time 2009
Of course you can then use the -format flag to format it any way you like.
Experiment! You will find the clock command is very powerful.
experiment
You can use a basedate