How to use clock scan to add 240 days to the existing date/time

Clovertech Forums Cloverleaf How to use clock scan to add 240 days to the existing date/time

Tagged: 

  • Creator
    Topic
  • #117115
    Omair Haq
    Participant

      Hello Everyone, I’m trying to populated in my Xlate 240 days from the date listed in MSH-7. So if MSH-7 is 202006121154; how can I add 240 days to this date and populated in another field in the message? I’m doing something like this inline code:

      regsub — {(\d{8})(\d+)} [lindex $xlateInVals 0] {\1 \2} dt
      set xlateOutVals

        ] -format %Y%m%d%H%M%S]]

         

        • This topic was modified 4 years, 6 months ago by Omair Haq.
      Viewing 0 reply threads
      • Author
        Replies
        • #117117
          Tipu Razaq
          Participant

            Command to add 240 days from a terminal session:

            set date_time_seconds [clock add [clock scan “202006121154” -format %Y%m%d%H%M] 240 days]

            After the above command, if you run the command: clock format $date_time_seconds

            It should display Sun Feb 07 11:54:00 CST 2021 (depending on your locale)

             

            To do this in a xlate:

            Mind you the command expects a time value in the format YYYYMMDDHHMM or else it may fail or convert the time incorrectly. I’m assuming 24 hour format for the hours.

            set time_in [lindex $xlateInVals 0]

            lset xlateOutVals 0 [clock format [clock add [clock scan $time_in -format %Y%m%d%H%M] 240 days] -format %Y%m%d%H%M]

            You can combine the above commands into a single command if you’d want like so:

            lset xlateOutVals 0 [clock format [clock add [clock scan [lindex $xlateInVals 0] -format %Y%m%d%H%M] 240 days] -format %Y%m%d%H%M]

             

             

            • This reply was modified 4 years, 6 months ago by Tipu Razaq.
            • This reply was modified 4 years, 6 months ago by Tipu Razaq.
        Viewing 0 reply threads
        • You must be logged in to reply to this topic.