Duration including start and end dates

Hi,
Current Duration calculation is a difference of the start date and end date.
how can i get the duration as a value inclusive of both the dates.
for ex:
start date=Mar 1,2018
end date= Mar 1, 2018
then,
duration is 0 days currently.

But i want to have 1 day in the chart.

Hi,

If you want to get 1 day duration, in your case end_date should be Mar 2, 2018.

In your case end_date is Mar 2. So it means that your task finishes Mar 2 at 00:00 and covers Mar 1 and don’t cover Mar 2. If you want to fully cover Mar 1 you should set end date “2018-03-02” or “2018-03-02 00:00”. Maybe you could at least use “2018-03-01 23:59:59”, but correct case is to use “2018-03-02” or “2018-03-02 00:00”.
If it necessary for you, you could correct task dates in onTaskLoading handler. (docs.dhtmlx.com/gantt/api__gant … event.html)

Thank You Polina.
In our system, user can input only a date but not timestamp.
System will automatically take it as “Thu Mar 01 00:00:00 GMT-0500 (EST) 2018”.
So is there any way to set the duration as one day in addition.

Hi Polina,

Below is my task data setting line in my script.
How can i use a function for defining “end_date” value as i am trying to apply your solution of setting the date to “2018-03-01 23:59:59”.
If i do it below way, its not giving any output.

taskdata.data.push({“id”:"<%<%builtin ID%>%>", “itemtype”:"<%<%builtin Type%>%>",“text”:"<%<%builtin Summary%>%>", “start_date”:"<%Planned Start Date%>", “actualEndDate”: “<%Planned Release End Date%>”, “user”: “<%Stakeholders%>”, “end_date”: calculateActualEndDate(), “state”: “<%<%builtin State%>%>”, “progress”: “<%Progress Percentage%>”, “open”: true, editable:false, “type”:“project”});

function calculateActualEndDate()
{
var actualenddate = new Date(<%Planned Release End Date%>);
actualenddate.setHours(23,59,59);
return actualenddate;
}

Thanks,
Navya.

Hello, it is not easy to change gantt logic and make inclusive values. It is much easier to change what gantt displays in the chart. For example, in this snippet we just decrease “end_data” parameter by one:
snippet.dhtmlx.com/28fb4103a

Update:
There are various ways to show inclusive dates, and the following article explains how it can be done:
https://docs.dhtmlx.com/gantt/desktop__loading.html#taskenddatedisplayampinclusiveenddates

1 Like

Hi!
Can I leave only start date value (without end date) in inline editor?
Or it will be filled automatically, if I remove it?

Hi @anton.m !

Sorry, I’m having troubles understanding your question. Could you please elaborate it or maybe word the question differently?

If I understood you correctly, you use the inline editor to set the start_date and end_date values. You have some logic to calculate the value of a duration.
You cannot make it so that if there is no end_date for the task, the duration is correspondingly assigned an empty value.