Invalid start_date argument for getDuration method

We get an issue only using Internet Explorer 11 with startDate or endDate equal to “0001-01-01T00:00:00”.

Can you fix this please.

Thanks

PS : We are using last version available (6.3.4)

Hello Dominique,
I don’t get any issues when I try to use that method in Internet Explorer:

Probably, the issue is related to Gantt configuration, but it is hard to suggest what might be wrong as I don’t see your code. Please, reproduce the issue in the snippet, then click on the “Share” button and send me the link:
https://snippet.dhtmlx.com/38ee1b370
Or send me an HTML file with all the necessary Javascript and CSS files.

Hello,

I think you missed the important point, the date should be “0001-01-01T00:00:00” !

Hello Dominique,
Thank you for the clarification, but I still cannot reproduce the issue:

Hello,

I have the same error but not everywhere.
Dates are the same on the DB and on the Gantt chart (01 march 2020).
It happens when I drag the task or when I drag the progress bar or when I save a task.
When it bugs, it seems like the div is always in drag mode, the cursor is still moving with the mouse
The backend give me a date like ‘DD/MM/YYYY’, I change it with new Date(Moment(myDate,“DD/MM/YYYY”).format())
It work on the first lines but not for other ones added later even the ones add by drag and drop from another vue component.

I finally found out where the problem came from, it was the constraint_date that was loaded with ‘null’ value.

hello Ramil,
I have the same error:
Uncaught (in promise) Error: Invalid start_date argument for getDuration method
at Object._getStartEndConfig (dhtmlxgantt.js:10:1)
at Object.hasDurationArguments (dhtmlxgantt.js:10:1)
at a.hasDuration (dhtmlxgantt.js:10:1)
at Object._hasDuration (dhtmlxgantt.js:10:1)
at Object.t._isProjectEnd (dhtmlxgantt.js:34:1)
at Object.e. [as _isProjectEnd] (dhtmlxgantt.js:10:1)
at Object._calculateBranch (dhtmlxgantt.js:34:1)
at Object. (dhtmlxgantt.js:34:1)
at c._eachItemCached (dhtmlxgantt.js:10:1)
at c.eachItem (dhtmlxgantt.js:10:1)
at Object.eachTask (dhtmlxgantt.js:10:1)
at Object._calculate (dhtmlxgantt.js:34:1)
at Object.isCriticalTask (dhtmlxgantt.js:34:1)
at Object.t.isCriticalTask (dhtmlxgantt.js:34:1)
at Object.template (ganttPageUtils.js:243:1)
at Object.render (dhtmlxgantt.js:10:1)
at Object.render_item (dhtmlxgantt.js:10:1)
at Object.render_items (dhtmlxgantt.js:10:1)
at a (dhtmlxgantt.js:10:1)
at c. (dhtmlxgantt.js:10:1)
at c.i (dhtmlxgantt.js:10:1)
at c.t.callEvent (dhtmlxgantt.js:10:1)
at c. (dhtmlxgantt.js:10:1)
at c.i (dhtmlxgantt.js:10:1)
at c.t.callEvent (dhtmlxgantt.js:10:1)
at c.refresh (dhtmlxgantt.js:10:1)
at Object.refreshData (dhtmlxgantt.js:10:1)
at dhtmlxgantt.js:10:1
at Object.t._quickRefresh (dhtmlxgantt.js:10:1)
at e. (dhtmlxgantt.js:10:1)
at e.i (dhtmlxgantt.js:10:1)
at e.t.callEvent (dhtmlxgantt.js:10:1)
at e.resize (dhtmlxgantt.js:10:1)
at Object.t.render (dhtmlxgantt.js:10:1)
at Object.i (dhtmlxgantt.js:34:1)
at Object.i (dhtmlxgantt.js:10:1)
at Object.t.callEvent (dhtmlxgantt.js:10:1)
at c. (dhtmlxgantt.js:10:1)
at c.i (dhtmlxgantt.js:10:1)
at c.t.callEvent (dhtmlxgantt.js:10:1)
at c.updateItem (dhtmlxgantt.js:10:1)
at Object.updateTask (dhtmlxgantt.js:10:1)

the version of Gantt_trial is 7.1.8

let taskId = “1514481151316242437”;

 let taskStart_CalendarDate = "2021-12-03";

 let taskDuration = 13;

 let projectStartDate = taskPlan.projectStartTime;
 let ganttTask = window.myGantt.getTask(taskId);
 if (ganttTask !== undefined) {
         ganttTask.start_date = new Date(taskStart_CalendarDate + " 00:00");
         ganttTask.end_date = getEndTimeByStart(ganttTask.start_date, taskDuration * 1 + 1);
         ganttTask.end_date = new Date(ganttTask.end_date + " 00:00");
         // console.log('777 ganttTask:', ganttTask);
         window.myGantt.updateTask(ganttTask.id);// error is here
         window.myGantt.refreshData();
 }

Hello Shatao,
Probably, you are generating an invalid date the second time you update the ganttTask.end_date parameter.
Here is an example:

If you want to increate the task duration, you need to update the duration parameter and then use the calculateEndDate method:

ganttTask.start_date = new Date(taskStart_CalendarDate + " 00:00");
ganttTask.duration = taskDuration;
ganttTask.end_date = gantt.calculateEndDate(ganttTask)

https://docs.dhtmlx.com/gantt/api__gantt_calculateenddate.html
Also, after updating a task, you don’t need to call the refreshData method as Gantt will repaint the change for the task in the updateTask method.
Here is the updated snippet:
https://snippet.dhtmlx.com/uxwfqqvu

1 Like