Baanboard.com

Baanboard.com (http://www.baanboard.com/baanboard/index.php)
-   Tools Development (http://www.baanboard.com/baanboard/forumdisplay.php?f=8)
-   -   Substract time period of actual date (http://www.baanboard.com/baanboard/showthread.php?t=70277)

BaBernd 1st August 2017 12:29

Substract time period of actual date
 
Hello to All,

I'd like to create a special print session where the user can choose a free time period (day, week, month, year) and a number for that periods.
For that the user can select events in past for a free selectable period.

Does there exist functions in Infor which will provide that or do I have to program it by my own?

Best Regards
Bernd

bdittmar 1st August 2017 13:54

utc.add()
 
Hello,
Code:

utc.add()
Syntax:

function long utc.add  (long i.utc, long year, long month, long day, long hour, long minute, long second, long o.utc)

Description


This adds years, months, days, hours, minutes, seconds to the input utc value and makes corrections if necessary.

It processes the parameters from bigger to smaller units:

First adds only years and the date is corrected (if started from a leap year)
Than the months are added and the date is corrected to an existing one.
The addition of days follow, and the result is so far the same hour, minutes, as it was in the beginning in the actual time-zone.
Finally the hours, minutes, seconds are added.

Arguments

long i.utc 
long year 
long month 
long day 
long hour 
long minute 
long second 
long o.utc 
 
Return values

0 Success.
1 Best guess.
2 Failure.
 
Context

This function can be used in all script types.

Example

This example shows the addition of days and hours across winter/summertime change

    in_utc = date.to.utc(2002,3,29,13,30,0)

    res = utc.add( in_utc, 0, 0, 1, 24, 0, 0, ou_utc )
The result in timezone "Europe/Amsterdam" is: ou_utc=1017577800, res = 0 (that is 2002.3.31 14:30:00)

This example shows the addition of days across winter/summertime change

    in_utc = date.to.utc(2002,3,29,13,30,0)

    res = utc.add( in_utc, 0, 0, 2, 0, 0, 0, ou_utc )
The result in timezone "Europe/Amsterdam" is: ou_utc=1017574200, res = 0 (that is 2002.3.31 13:30:00)

This example shows the substraction of 1 month from March 31st, 2000.

        in_utc = date.to.utc(2000,3,31,9,0,0)

        res = utc.add( in_utc, 0, -1, 0, 0, 0, 0, ou_utc )
The result in timezone "Europe/Amsterdam" is: ou_utc=951811200, res = 1 (that is 2000.2.29 9:0:0)

Regards

mark_h 1st August 2017 14:28

If it is like a couple of sessions I have done then I think you need to code it yourself. My session you only get weeks and months. So I have a simple drop yes/no drop down for printing by months(I think). Anyway if you enter yes - then the label for the next input range is year/month. If no I change the label to year/week. I think it defaults to like a year range - so the default for this month would be 2017/8 to 2018/8. If they pick no it changes to something like 2017/31 to 2018/30. Something like that.

I am thinking you could do a new domain with year, month, week, day - then do the same type deal with asking for input range. Of course this is assuming I understood the request to start with.

BaBernd 1st August 2017 15:20

Hello Mark, Hello Bernd,

thanks a lot for fast reply.

The function utc.add() Bernd Dittmar has given works very fine. Simple and easy to integrate. Also well described :-).
Thanks a lot for that!

Best Regards
Bernd


All times are GMT +2. The time now is 00:59.


vB.Sponsors
©2001-2018 - Baanboard.com - Baanforums.com