convert date time

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf convert date time

  • Creator
    Topic
  • #50642
    Mason Miller
    Participant

      I am trying to add a date and time to a transcation I can use @now but I need to convert to YYYYMMDDHHMM.

    Viewing 6 reply threads
    • Author
      Replies
      • #66936
        Tom Rioux
        Participant

          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

        • #66937
          Mason Miller
          Participant

            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]

            set xlateOutVals $dt

            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”

          • #66938
            Tom Rioux
            Participant

              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:

              set dt [clock format [clock scan [exec date]] -format %Y%m%d%H%M]

              set xlateOutVals $dt

              That should get you what you want!

              Tom

            • #66939
              Mason Miller
              Participant

                Ok I tried that and got this error

                Tcl callout error

                erroCode: POSIX ENOENT {no such file or directory}

                errorInfo:

                couldn’t execute “date”: no such file or directory

                   while executing

                “exec date”

              • #66940

                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.

                Code:

                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:

                Code:

                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)

              • #66941
                Charlie Bursell
                Participant

                  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

                • #66942
                  Mason Miller
                  Participant

                    Thanks you very much that worked.

                Viewing 6 reply threads
                • The forum ‘Cloverleaf’ is closed to new topics and replies.