Adding a duration to a date to give a new date - Forum - Rollbase - Progress Community

Adding a duration to a date to give a new date

 Forum

Adding a duration to a date to give a new date

  • Hi, still getting my head around Java and RB. Seems to be a lot of ways to do the one thing. I would like to use RB to generate Java code to give me a new date from a known date and a duration.

    What I tried is:

    Original Formula 
    {!return_DT} = {!startDate} + {!duration}
    



    Parsed Formula 
    001 Fri Oct 10 2014 16:00:00 (EST) = Tue Nov 25 2014 19:44:00 (EST) + 23400000
    
    

    Formula return type: Date/Time (Adjust to user time zone) 

    Error 
    Error missing ; before statement (line #1) in formula:
    Fri Oct 10 2014 16:00:00 (EST) = Tue Nov 25 2014 19:44:00 (EST) + 23400000
    

    Any help most gratefully accepted.

  • Hello,

    Can you provide the steps you are doing in Rollbase? Are you referring to JAVA or Javascript?

    Thank you,
    Gian
  • Hi herveyq,
     
    Instead of {!return_DT} = {!startDate} + {!duration}
     
    In the trigger properties, select the return_DT in Field to Change
     
    And try:
    return new Date(Date.parse("{!startDate}") + {!duration});
     
    Regards,
    Ricardo
     
     
     
    From: Gian Torralba [mailto:bounce-gtorralb@community.progress.com]
    Sent: Wednesday, November 19, 2014 9:12 AM
    To: TU.Rollbase@community.progress.com
    Subject: RE: [Technical Users - Rollbase] Adding a duration to a date to give a new date
     
    Reply by Gian Torralba
    Hello,

    Can you provide the steps you are doing in Rollbase? Are you referring to JAVA or Javascript?

    Thank you,
    Gian
    Stop receiving emails on this subject.

    Flag this post as spam/abuse.

  • Hi Gian, javascript.

    Thanks

    Gil

  • Hello,

    You can parse the token return into a date as Ricardo has posted. You can also add the duration by converting the duration into milliseconds.

    var date = new Date("{!date_token}");
    date = new Date(date.setHours(0,0,0,0)); /*sets the date to 12:00 am*/
    date = date.setMilliseconds(10000); /*sets the time of the date variable*/

    return date;

    Thank you,

    Gian