Profile picture for user schmidtm

Hi there!

I am searching for a date object that contains the current system date. Once I have this, I want to subtract 30 days and get therefore get another date. Does anybody know how I can access the system date in the ARIS scripting language? And are there possiblities to format the date (e.g. DD.MM.YY) to compare it with other dates from user defined attributes?

Thanks in advance!

Markus

by Charles Tarel
Posted on Tue, 06/28/2011 - 02:27

Hello Markus,

you can use the standard Date() object in javascript to achieve that:

var today = new Date() // this will give you the current system date in a Date object

today.setDate(today.getDate() - 30) // this will take 30 days off today's date

If you prefer a more precise time you can use today.getTime(), that will return the number of millisecond since 01/01/1970. I hope it helps.

0
by Markus Schmidt Author
Posted on Tue, 06/28/2011 - 06:28

Hello Charles!

Thanks a lot for this very useful hint, that will keep me going!

However, this problem solved keeps another one popping up. Now I have the system date but I can't compare it with my user defined date attribute. What I want to do is to compare both month if they differ. I get the system date's month with the method date.getMonth().

The system date delivers:

Tue Jun 28 2011 06:24:37 GMT+0200 (MESZ)

I have defined a user attribute (fdate) of the type date which delivers in the report:

28.06.2011

Unfortunately I can't use the method fdate.getMonth() to compare the current month with the month of the user defined date attribute.

Do you have any suggestions for this case? What is the type within ARIS of user defined date attributes? Thanks very much in advance!

Markus

0
by Charles Tarel
Posted on Thu, 06/30/2011 - 01:44

Hello Markus,

if you are using Object.Attribute().getValue(), ARIS will return you a String. You cann usethat string to create a Date if you want to:

var fdateString = aObject.Attribute(XXXX, nLocal).getValue() // this will get the value of the custom attribute you created

var fdateDate = new Date(fdateString) // this will create a  Date object from the string value of the attribute

once you have your dates you can compare using standard comparisons:

var today = new Date()
var fdateDate = new Date(fdateString)
 
if (fdateDate > today) {
     // fdate is in the future
}

I hope it helps

0
by Markus Schmidt Author
Posted on Fri, 07/01/2011 - 07:32

Hello Charles!

Thank you for your help! It really worked that way. Another way I discovered is to get the month with the methode substring.

Greetings

Markus

0
by Jan de Groot
Posted on Tue, 07/05/2011 - 10:35

Nice to read this, but actually i am searching to convert a date from "Nov 5, 2010 6:49:15 AM" into "05-11-2010" (dd-mm-yyyy)

How can i do this, both examples does not work:

          strtypeo = __toString(ocurrentattribute.Type());

          strvalue = __toString(__toString(ocurrentattribute.GetValue(true)));

          if (strtypeo == "Time of generation") {

            formatter = new SimpleDateFormat("dd-mm-yyyy");

              strgenerationm = formatter.format(strvalue);      

           }

or

          strtypeo = __toString(ocurrentattribute.Type());

          strvalue = __toString(__toString(ocurrentattribute.GetValue(true)));

          if (strtypeo == "Time of generation") {

            strgenerationm = dateFormat(strvalue,"dd-mm-yyyy");

           }

 

0
by Markus Schmidt Author
Posted on Tue, 07/05/2011 - 15:00

Hi Jan!

Yes, I was also looking for exactly that conversion but I haven't found a possibility to use the java.util.* and the java.text.* packages of java in javascript. And the text-package contains the new SimpleDateFormat object. I also tried this, but I was not able to import them.

What you also could do is to get the day, month and year like this and build up a date string with this.

var date = new Date();

var day = date.getDay();

var month = date.getMonth();

var year = date.getYear();

string convDate = day + "-" + month + "-" + year;

so the string convDate should contain for example 05-07-2011

greetings,

Markus

0
by Marc Lehmann
Posted on Tue, 07/05/2011 - 15:40

 

Hi all,

There shouldn't be any access limitations for these packages - just use the fully-qualified class name as shown below.

Regards

Marc

var now = new Date();

var formatter = new java.text.SimpleDateFormat('dd-mm-yyyy');

var result = formatter.format(now);

 

0
by Amol Patil
Posted on Fri, 07/08/2011 - 13:13

Hi all,

You can use "new java.util.Date()" or simply "new Date()" to create the date object and can see the methods that can be used

http://download.oracle.com/javase/1.5.0/docs/api/java/util/Date.html

Just some things to remember

1. If you use it in Reports, then the date returned is server date. Using it in Macro returns your local system date.

2. The month returned by Date.getMonth() method is 1 month less, as the index starts from 0. Same while creating date object, the number provided for month should be -1 the actual month number. Try these with some small test script.

Comparing Date :-

For comparing dates, string compare is not a good option, and it may include a lot of comparing logic also. The best way to comapare the date, or to subtract some no of days, or to find out the difference of dates, is to convert both the dates to milliseconds and do the comparision. Date.getTime() method can give the milliseconds.

@Markus, comparing the date might be wrong if both the dates are in different GMT string. 30 days milliseconds can be found out by 30*24*60*60*1000

So your steps should be

1. Read the date stored in attribute as string.

2. Create a Date object from that string. Find out the milliseconds.

3. Get the system date. Find out the milliseconds.

4. Find out difference in Milliseconds.

5. Find out days, Days = (((((Difference in Milliseconds)/1000)/60)/60)/24). You can use Math.round(), Math.floor() or Math.ceil() methods to round the number if required.

Now you can compare the Days with 30 or any other value.

Thanks,

Amol Patil

0
by Jan de Groot
Posted on Tue, 07/12/2011 - 12:06

Thanks,

I have found the solution (use MM to see the month, mm to see minutes!) :

  strvalue = __toString(__toString(ocurrentattribute.GetValue(true)));
if (strtypeo == "Time of generation") {
    strdate = new Date(strvalue);
    formatter = new java.text.SimpleDateFormat("dd-MM-yyyy");
    strdate = new Date(strvalue);
    strgenerationm = formatter.format(strdate);
}

 

0

Featured achievement

Rookie
Say hello to the ARIS Community! Personalize your community experience by following forums or tags, liking a post or uploading a profile picture.
Recent Unlocks

Leaderboard

|
icon-arrow-down icon-arrow-cerulean-left icon-arrow-cerulean-right icon-arrow-down icon-arrow-left icon-arrow-right icon-arrow icon-back icon-close icon-comments icon-correct-answer icon-tick icon-download icon-facebook icon-flag icon-google-plus icon-hamburger icon-in icon-info icon-instagram icon-login-true icon-login icon-mail-notification icon-mail icon-mortarboard icon-newsletter icon-notification icon-pinterest icon-plus icon-rss icon-search icon-share icon-shield icon-snapchat icon-star icon-tutorials icon-twitter icon-universities icon-videos icon-views icon-whatsapp icon-xing icon-youtube icon-jobs icon-heart icon-heart2 aris-express bpm-glossary help-intro help-design Process_Mining_Icon help-publishing help-administration help-dashboarding help-archive help-risk icon-knowledge icon-question icon-events icon-message icon-more icon-pencil forum-icon icon-lock