TACTIC Open Source
How to cal duration with start end dates - Printable Version

+- TACTIC Open Source (http://forum.southpawtech.com)
+-- Forum: TACTIC Open Source (http://forum.southpawtech.com/forumdisplay.php?fid=3)
+--- Forum: TACTIC Discussion (http://forum.southpawtech.com/forumdisplay.php?fid=4)
+--- Thread: How to cal duration with start end dates (/showthread.php?tid=104)



How to cal duration with start end dates - EricTsuei - 04-27-2020

How to cal duration with start end dates?
is there some exp like  
@GET(.bid_start_date) - @GET(.bid_end_date)?
or like excel 
@NETWORKDAYS(@GET(.bid_start_date) , @GET(.bid_end_date))


RE: How to cal duration with start end dates - remkonoteboom - 04-27-2020

It should have been possible to just subtract the dates:

@GET(.bid_end_date) - @GET(.bid_start_date)

However, I found that there is a bug in the code, in src/pyasm/biz/expression.py

1050 # convert result to seconds if it is a timedelta
1051 if isinstance(result, datetime.timedelta):
1052 result = results.seconds

This doesn't take days into account and should maybe have been:

1052 result = result.days*24*3600 + result.seconds

However, looking at it now, I think it should return a timedelta and that this conversion to seconds is incorrect. This was probably done a while ago when datetime and timedelta were not so well supported in Python2 (yes, there was a time when lots of things didn't handle dates very well).

I think the best solution would be to comment out 1051 and 1052 completely. I am not sure what code would break if that's the case.

Note: this does not do the same as @NETWORKDAYS which calculate business days. All the date tools for calculating this are in TACTIC code but have not been mapped to the expression language.


RE: How to cal duration with start end dates - listy - 04-28-2020

Sorry. But what is @NETWORKDAYS ? Doe this even exists???


RE: How to cal duration with start end dates - remkonoteboom - 04-28-2020

@NETWORKDAYS is an Microsoft Excel function (which is actually where we got the @ notation from). It is not a TACTIC expression language function.

What it does in excel is give the business days between two dates (not including weekends and holidays).


RE: How to cal duration with start end dates - EricTsuei - 04-29-2020

ok, I have  comment out 
#if isinstance(result, datetime.timedelta):
#result = results.seconds

but I get this result, "2 days, 0:00:00"
(see attachment)

how can I only get the days in int format?


RE: How to cal duration with start end dates - listy - 04-29-2020

May be it would be easier to you to write custom class for your column?