abas-ERP (FO-Language): Exact time difference between 2 abas dates

277 views Asked by At

Is there any FO-native possibility for getting the exact difference between two abas date objects?

I have a AJO-based solution comparing two Calendar-Objects, but it's too slow for my use-case (it's called to many times) and I hope there is a native solution.

And what is the highest accuracy the abas dates (GD-Fields) can represent? Just Seconds or is there a way to get a UNIX-time-stamp or something comparable for a higher precision.

1

There are 1 answers

8
Alexander Baltasar On BEST ANSWER

Yes, you can use the GP4 type.

.type GD19 xdbegin xdend
.type GP4  xgdiff
.formula U|xdbegin = "1.1.2015 00:00:00"
.formula U|xdend   = "1.1.2016 00:00:00"
.formula U|xgdiff  = U|xdend-U|xdbegin
'U|xgdiff'

output will be 365D00h00m00s

Now you can convert it e.g. into seconds:

.type text xtcmd
.type int  xisec
.formula U|xtcmd = "formula U|xisec = " + F|regreplace(F|regreplace(F|regreplace(F|regreplace('U|xgdiff', "D", "*24*60*60+"), "h", "*60*60+"), "m", "*60+"), "s", "")
.'U|xtcmd'

As far as I know "seconds" is the highest precision you can use in FO. If you need more, you have to use (as you already mentioned) UNIX-time-stamps