DavidCB
6th September 2002, 13:51
How can I know the difference between two dates?
Isn't there any functions that allows me to solve the problem?
Thanks in advance
DavidCB
günther
6th September 2002, 14:18
Dates (domain tcdate, domain tidate) have values of type long. You can just calculate the difference as with any other numbers, e.g.
domain tcdate today, yesterday, tomorrow
today = date.num()
yesterday = today - 1
tomorrow = today + 1
message("today is %D002, yesterday was %D002, tomorrow will be %D002", today, yesterday, tomorrow)
FransG
6th September 2002, 16:24
Note that in BaanERP domain tcdate is not a DATE type but a UTC type.
Kees de Jong
6th September 2002, 16:39
Don't forget to search the BaanERP Programmers' Manual (http://www.baanboard.com/baanboard/bblibrary.php?s=&action=show_library) for this kind of information.
DavidCB
6th September 2002, 16:42
Thank you very much for your quick response.
In fact the dates ar UTC, therefore I couldn't get the difference.
DavidCB
lbencic
6th September 2002, 17:30
The UTC dates are good and bad. Math with dates is much harder.
Try the function
utc.to.local(long utc, ref long local_days, ref long local_time)
Then, local_days is stored as a long number, which you can do math on. Put it back using the
local.to.utc(long local_days, long local_time, ref long utc)
Good luck
DavidCB
6th September 2002, 17:59
Really, what I want is to obtain the difference in days of these two fields: whinh430.cdat - tdsls401.ddta.
The operation made directly comes out erroneous (it's a date from 1970)
I don't know the way to remove these two fields to apply the functions that you explain to me.
Greetings
DavidCB
lbencic
6th September 2002, 18:11
It returns the number of days since I'm not sure which date. The number it returns is not a number that makes sense as a date. You can use it to see differences in days as follows:
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
Hope that helps
DavidCB
6th September 2002, 18:29
Thank you very much lbencic, your code has help me a lot, it has worked perfectly
fmchong
21st December 2009, 09:14
Dear All,
Thank you very much. Problem resolved.
pegaga1979
26th November 2014, 06:51
It returns the number of days since I'm not sure which date. The number it returns is not a number that makes sense as a date. You can use it to see differences in days as follows:
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
Hope that helps
Hi, may i know in report layout, the field should in what domain?
bhushanchanda
26th November 2014, 09:16
Hi,
Try tcmcs.long