Adding a duration to a date to give a new date

Posted by herveyq on 19-Nov-2014 02:12

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.

All Replies

Posted by Gian Torralba on 19-Nov-2014 08:11
Hello,

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

Thank you,
Gian
Posted by Ricardo Rafols on 19-Nov-2014 08:57
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
 
 
 
[collapse]
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.

[/collapse]
Posted by herveyq on 23-Nov-2014 01:11

Hi Gian, javascript.

Thanks

Gil

Posted by Gian Torralba on 24-Nov-2014 06:56

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

This thread is closed