Clovertech
› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › convert date time
I am trying to add a date and time to a transcation I can use @now but I need to convert to YYYYMMDDHHMM.
Set this tcl in your xlate to see if it works correctly:
set dt [clock format [clock scan [exec date]] -format %Y%m%d%H%M]
set xlateOutVals $dt
You can break it up into multiple lines if you feel its too long this way.
Hope this helps…
Tom Rioux
I am not sure I am doing this right but here is what I am using
set date $xlateInVals
set dt [clock format [clock scan [exec $date]] -format %Y%m%d%H%M]
and below is the error I am getting
errorInfo:
couldn’t execute “{Tue Feb 17 15:55:10 2009}”: no such file or directory
while executing
“exec $date”
If you are just wanting to copy the current date and time to the outbound field, then on your inbound side just put some bogus entry like:
=NO_VALUE
then in your tcl fragment, enter the code just lik below:
That should get you what you want!
Tom
Ok I tried that and got this error
Tcl callout error
erroCode: POSIX ENOENT {no such file or directory}
couldn’t execute “date”: no such file or directory
“exec date”
I put the following code into a file called test.tcl and then I executed the file by typing “tcl test.tcl” on the command line.
lappend xlateInVals [exec date] set dt [clock format [clock scan [exec date]] -format %Y%m%d%H%M] set xlateOutVals [list $dt] puts [lindex $xlateOutVals 0]
The result was: 200902171533
So, in your Xlate do this:
set dt [clock format [clock scan [exec date]] -format %Y%m%d%H%M]; set xlateOutVals [list $dt]
(copy and paste it)
-- Max Drown (Infor)
I am a bit confused about why the need to exec date and sacn the return value. It may work but why when there are built in Tcl commands to do it?
clock format [clock seconds] -format %Y%m%d%H%M
Thanks you very much that worked.