IBM Sterling Transformation Extender

Sterling Transformation Extender

Come for answers, stay for best practices. All we're missing is you.

 View Only
  • 1.  Adding seconds to CURRENTDATETIME

    Posted Mon May 19, 2025 10:20 AM
    Edited by Lorraine Rizzuto Tue May 20, 2025 09:13 AM

    I have a requirement to add 1 second to CURRENTDATEDATE and assign to output DateTime field. Since, we do not have any inbuilt function for the same, need to know if we have any other simple way for the same



    ------------------------------
    Zaid Lalkate
    ------------------------------

    #IBMSterlingTransformationExtender

    #IBM-Websphere-Transformation-Extender



  • 2.  RE: Adding seconds to CURRENTDATETIME

    Posted 17 days ago

    Can anyone reply on this.

    ------------------------------
    Zaid Lalkate
    ------------------------------

    #IBMSterlingTransformationExtender

    #IBM-Websphere-Transformation-Extender



    ------------------------------
    Zaid Lalkate
    ------------------------------



  • 3.  RE: Adding seconds to CURRENTDATETIME

    Posted 16 days ago

    If you could change your need to add one minute instead of one second the ADDMINUTE() function would make this very simple.

    If you actually need to add a second you have a tough problem on your hands.  Time-based math is not fun, but the typical approach to handling it is to make your time object a numeric, do the math, then revert from numeric to time.  This approach solves the problem of having 59 seconds plus one, which makes 00 seconds plus 1 new minute.  The function to revert numeric to time handles all that for you.

    There are no built in functions to do time to number but the formula is not difficult:

    TEXTTONUMBER(FROMDATETIME(CURRENTTIME(), "{HH24}")) * 36000000) +
    TEXTTONUMBER(FROMDATETIME(CURRENTTIME(), "{MM}")) * 600000) +
    TEXTTONUMBER(FROMDATETIME(CURRENTTIME(), "{SS3-3}")

    this returns a numeric value of accumulated milliseconds in a given day.  You could enhance to add days as well if needed.

    With a numeric value representing the current time in milliseconds you can add 1000 to that to get a new value one second beyond.  the you would reverse the math, getting the hour, minute, and milliseconds by dividing and subtracting as you go.

    Not pretty at all and a lot of simple math but it would work.  

    Other alternatives would be to use Java and a JEXIT() call.  That's a heavy lift just to add one second to a given time.  Same for shelling out to the OS - Linux has some easy ways to add one second with enhanced date command line options but still a heavy lift for a small reward.

    I would get the OK to just add a minute if at all possible.  quick and easy.  Otherwise the math approach would work after you test out the formulas to ensure you're getting what you want.

    Jim



    ------------------------------
    Jim Davee
    ------------------------------



  • 4.  RE: Adding seconds to CURRENTDATETIME

    Posted 16 days ago

    As you can only use the ADDMINUTES() function to add minutes, you could try using the DATETONUMBER() or TONUMBER() functions to get the value as a number and then try adding 1 before converting it back to a DateTime field? This is what comes to mind but not able to try it at the moment ;-) Hope this is helpful :-)



    ------------------------------
    Chris Clews
    ------------------------------