Skip to main content

Posts

Showing posts with the label mod

Calculate Time Consumption in hours in Ax 2012

Code to get total time consumed between two times means if time one is 14:10 and time two is 15:40 then you want to get difference time in hours only like in this example it will be 1.5 hours. Getting time in hours in very difficult but you can get it easily by writing one simple method. # int seconds, minutes, hours, totalTime; # str timeStr = "",minstr=""; # # if (_startTime > _endTime) # { # totalTime = _endTime + (str2time('23:59:59') - _startTime); # } # else # { # totalTime = _endTime - _startTime; # } # # seconds = totalTime mod 60; # minutes = totalTime mod 3600 div 60; # hours = totalTime div 3600; # # if (hours > 0) # if (hours == 1) # timestr = timeStr + strFmt("%1", hours); # else # timestr = timeStr + strFmt("%1", hours); # #

Show Random number in MSD axapta

To Show Random number in axapta you can try below code through job. Random is class name which has nextInt method to get next random number. Random Random = new Random(); int RandomNo,RandomwithMod; ; RandomNo=Random.nextInt(); RandomwithMod=Random.nextInt() MOD 1000; info(Strfmt('%1%2',RandomNo,RandomwithMod));