pegaga1979
30th October 2014, 05:23
Hi all,

I would like to calculate days start from ordering date until today date.
i put in form field "utc.num() - tdpur401.odat" .
Example: 30-10-2014 10:55 - 23-09-2014 09:32 . And it return value 07-02-1970 08:53.
I would like to have it in integer which that supposed 37days.

anyone can help me?

vamsi_gujjula
30th October 2014, 05:53
UTC date starts...from 1-1-1970.... and every second is added from then...

So ...you have to convert both UTC.dates to baaniv dates (tfglddate)

And then subtract.

Or else

(Utc1-utc2)/ 24*60*60 this will also give what you want...

bhushanchanda
30th October 2014, 09:40
Also search for similar threads.

Thread (http://www.baanboard.com/baanboard/showthread.php?t=6589&highlight=difference+dates)

long lng.cdat, lng.ddta, lng.ctim, lng.dtim, days.diff

utc.to.local(whinh430.cdat, lng.cdat, lng.ctim)
utc.to.local(tdsls401.ddta, lng.ddta, lng.dtim)

days.diff = lng.cdat - lng.ddta

pegaga1979
26th November 2014, 12:53
i've put the script as below:

extern domain tcdate today, orderdate
domain tcmcs.long no.of.days
long lng.cdat, lng.ddta, lng.ctim, lng.dtim

before.program:
today = utc.to.local (date.num (), lng.ddta, lng.dtim)
orderdate = utc.to.local (tdpur401.odat, lng.cdat, lng.ctim)
detail.1:
before.layout:

no.of.days = lng.ddta - lng.cdat

and the result i get for:
no.of.days = 16400
lng.ddta = 735563
lng.cdat = 719163

I should get 26.11.14 - 10.11.14 = 16 days but failed :(

im not sure, which is incorrect...

andreas.toepper
26th November 2014, 13:13
719163 means 01.01.1970, that's the startdate of UTC. I'd say tdsls401.odat is empty (=0)

Oh, could you please check wether tdpur401.odat is allready filled in before.program?
I think before.program will be executed without having data transfered into the input fields, so tdpur401.odat may be empty.
You may need to calculate the dates in the first before.field section of your report (or in detail.1/before.layout), when the input fields are filled with data from the session.

bhushanchanda
26th November 2014, 13:16
Hi,

You need to get Order date in before.layout.

extern domain tcdate today, orderdate
domain tcmcs.long no.of.days
long lng.cdat, lng.ddta, lng.ctim, lng.dtim

before.program:
today = utc.to.local (utc.num(), lng.ddta, lng.dtim)

detail.1:
before.layout:
orderdate = utc.to.local (tdpur401.odat, lng.cdat, lng.ctim)
no.of.days = lng.ddta - lng.cdat

pegaga1979
27th November 2014, 06:17
Thank you very much all,

it is run ok now.
you all saved my day :)