Include End Date in Day Calculation and Display in Chart


#1

Hi,

I need to Calculate End Date Day and also display in chart. For Example :
Start Date : 01/12/2014
End Date : 15/12/2014
Exclude : saturday and sunday.
So it will display 10 days. (Exclude last day 15/12/2014).

I need to include last day 15/12/2014 in calculation.

How can I do that?

Thanks


#2

Hello,
Currently there is no option for such mode. The dates are interpreted not inclusively, e.g. 20-05-2014 is interpreted as 00:00:00 20 May 2014 - which means task ends by 20 May, not including the day.

If you want to show dates inclusively, you can try to modify a date templates, in order to make them show end of the previous day
docs.dhtmlx.com/gantt/api__gantt … plate.html
Or manage the end date somehow during using the public events, e.g. docs.dhtmlx.com/gantt/api__gantt … event.html


#3

Hello,
I know the topic is a few years old, but I have the same problem, i need to include end date in calculation and display in chart.
I tried to use the example, but i couldn’t do it.
I have to show correct end_date on the gantt. In the lightbox i have a time field with start and end, and i need to show correctly. I have a resources gantt with hours. And i need to save the end_date on the db. how do i do it?
Thank you.


#4

Hello,
There is no built-in way to change how Gantt works.
There are various workarounds that you can use, but the easiest way would be to subtract 1 minute from the end_date of the task before updating it.
Here is the snippet that demonstrates how it works:
http://snippet.dhtmlx.com/5/6c6103859

And you can try other workarounds:
http://snippet.dhtmlx.com/1c2df2d6a
https://snippet.dhtmlx.com/a464a8da2

And i need to save the end_date on the db. how do i do it?

Unfortunately, I don’t have a solution for the server-side. You need to implement a custom solution.


#5

Hi. Thank you.
I did it, but I have a problem. When i link 2 tasks, the 2nd task get bug. When i refresh the page, everything is ok.
I have the same problem when i move a task

Example:
(Before i link tasks)
image

(After i link tasks)
image

(After i refresh the page)
image

I try to use this code:

gantt.attachEvent("onAfterTaskUpdate", function (id, task) {
          gantt.refreshTask(id);
          gantt.render();
}

But without success.
Please help me. Thanks.


#6

Hello,
Unfortunately, I couldn’t reproduce the issue even if I add autoscheduling:
http://snippet.dhtmlx.com/0ecea6d42

Please, reproduce the issue in the snippet, then click on the “Share” button and send me the link.
Or send me an HTML file with all the necessary Javascript and CSS files.


#7

Hi,

I know the topic is a few years old, but I have the same problem. I used a solution by ramil and it works great except for milestones.
I have the following examples, where you can see that now the end_date is before start_date, which is not ok:

I tried to make another check for duration, but than milestones on edges does not match with parent dates:

http://snippet.dhtmlx.com/5/a5c14c900

Is there any good workaround for this?

Regards,
Marko


#8

Hello Marko,
For milestones, you can use the template function in the column configuration where you can return any data or HTML elements:
https://docs.dhtmlx.com/gantt/desktop__specifying_columns.html#datamappingandtemplates
You can return an empty string or the actual end_date.
By default, you cannot set the end_date via the lightbox, but you can do that with the inline editors. As milestones ignore the end_date parameter, there is no point to allow users to try to set that value. So, you can return false in the onBeforeEditStart event handler for milestone tasks:
https://docs.dhtmlx.com/gantt/desktop__inline_editors_ext.html#events
Here is an example of how it might be implemented:
http://snippet.dhtmlx.com/5/93e6a2aff


#9

Hi ramil, thank you for your answer.

Unfortunately your solution does not solve my problem completely. If I put milestone at the end, than parent task end date should be equal to milestone start date (but in gantt there comes to one day lack). I prepared an image comparing Project and DHTMLX and I wonder if there is there a chance to match those gantt grids to look same?

Here is an example from the image:
http://snippet.dhtmlx.com/5/87cf14ad2

Regards,
Marko


#10

Hello Marko,
Thank you for the clarification.
It works that way because the milestone actually starts 04 April, but its duration is 0.
It seems that there is no easy solution for that.

I would suggest adding a custom task type that will look like a milestone, but it can behave like a regular task with any duration.
Here is an example:
http://snippet.dhtmlx.com/5/b5c6ae5f3