Announcement

Collapse
No announcement yet.

CL date/time arithmetic

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • CL date/time arithmetic

    When manipulating dates in CL I often resort to calling an RPG program. I finally created a command to perform date/time arithmetic. Others might find it useful so I posted the source: sourceforge.net/projects/ibm-i-cl-date-arithmetic/files/

    It's simple: CHGDTETME DTETME(*CURRENT) DURATION(*SUB *DAY) RTNVAL(&RESULT)
    (get yesterday's date)

    And flexible: CHGDTETME DTETME('1988-06-01-00.00.00') DURATION(*ADD '0032-09-21-14.30.00') RTNVAL(&RESULT)
    (Thirty two years, nine months, twenty one days, fourteen hours and thirty minutes will be added to DTETME, return value contains '2021-03-22-14.30.00'.)

  • #2
    Thanks, I will take a look.

    Comment


    • #3
      The command processing program uses _INCTS and _DECTS to increment/decrement a timestamp by a duration. I chose them instead of %bifs because it treats the entire duration is a single entity versus bifs which require each part of a timestamp be handled individually. Most of the pgm is setting up a bunch of datastructures, it's pretty straightforward.

      Comment

      Working...
      X