Clovertech
› Clovertech Forums › Cloverleaf › Adding days to date message recieved using system time tcl
I am trying to add days to the day the message was received, using system time. Any ideas on how to code for this?
<p>What do you mean? Are you trying to add more time to a date/time field in the message? </p>
Correct! Say date and time of message was 20200817142811. I would like to add 11 days to that using system time as opposed to MSH 7
Here’s the TCL command. Takes your date/time, converts it to seconds, adds 11 days, converts it back to your desired date format of %Y%m%d%H%M%S (year, month, day, hour, minutes, seconds)
This is all assuming 24 hour clocks, not 12 hr
clock format [clock add [clock scan 20200817142811 -format %Y%m%d%H%M%S] 11 days] -format %Y%m%d%H%M%S
New date/time: 20200828142811
Thank you
I just tried this at the tcl prompt to get 3 days in the future, you can probably google better examples of clock scan to fit your exact needs:
clock format [clock scan “72 hours”] -format %Y%m%d%H%M%S 20200821122548
…