Having a problem calculating duration with start date included


#1

In Dhtmlx we realized that duartion can be calculated start to end or start duration or duration to end based on perfrence however we would like count the start to date as 1 not zero.
I Sow in many questions the answer is to change the display. Then, there will be the problem of exporting to xml MS Project or XML PM6 it will have conflict when it passes through Api and reault to incoherent output.
Is there any round about it
It is diffeent in MS project
Unfortunately, when we upload from MS project to DHTMLX Ganett the duration is calculated automatically because we don’t wnat to change the grid time slots

Any suggestions of how to add this day in calculation without playing with start or end date

var dateEditor = gantt.config.editor_types.date;


gantt.config.duration_unit = "day";


gantt.config.work_time = true;
gantt.setWorkTime({day : 1, hours: true});
gantt.setWorkTime({day : 2, hours: true});
gantt.setWorkTime({day : 3, hours: true});
gantt.setWorkTime({day : 4, hours: true});
gantt.setWorkTime({day : 5, hours: true});
gantt.setWorkTime({day : 6, hours: true});
gantt.setWorkTime({day : 7, hours: true});


gantt.config.columns = [
  {name: "text", label: "Name", tree: true, width: 200, editor: textEditor, resize: true},
  {name: "duration", label: "Duration", width:80, align: "center", editor: durationEditor, resize: true},
  {name: "start_date", label: "Start", width:140, align: "center", editor: startDateEditor, resize: true},
  {name: "end_date", label: "Finish", width:140, align: "center", editor: endDateEditor, resize: true}
];

gantt.calculateEndDate({start_date: new Date("2022/01/13"), duration:5});
console.log(gantt.calculateDuration({start_date: new Date("2022/01/13"), end_date: new Date("2022/01/15")}));


gantt.init("gantt_here")

#2

Hi,
Gantt uses the non-inclusive duration. There is no way to change how Gantt works, but you can change what is displayed to the users by using the templates:
https://docs.dhtmlx.com/gantt/desktop__loading.html#taskenddatedisplayampinclusiveenddates
https://docs.dhtmlx.com/gantt/api__gantt_task_end_date_template.html
Here is an example of how it works:
https://snippet.dhtmlx.com/ixxx7r2i

Also, you can set the duration_unit to hour and enable the work_time parameter:

Gantt will show the same dates in the grid because the hours will be different.
To show the duration in days and even in fractional values, you can use the formatters:
https://docs.dhtmlx.com/gantt/desktop__formatters_ext.html#durationformatter

Here is an example with the date input type in the inline editors:
https://snippet.dhtmlx.com/j2axq1lu
Here we need to modify the dates because the input element with the date type doesn’t have the hour values.

Here is another example with the datetime-local input type in the inline editors:
https://snippet.dhtmlx.com/cy7tht5r
The input element may take more space, but it will store the dates more accurately.