task that end at the day end

Good morning,

when i add a task in my  task collection (ListaReg) I use:

   Dim TDM As New TaskDetails

   TDM.StartDate = New Date(Now.Year, Now.Month, Now.Day)

   TDM.FinishDate = TDM.StartDate.AddDays(3)

   VM.ListaReg.Add(TDM)

if we are at the first of december, in the task grid i can see start date: 01/12/2021 (12:00 AM) and finisch date 03/12/2021 (12:00AM).  The duration i get is 2 days because the start date is at 12:00 AM (midnight) of  the first day (at the beginning of it) and the end date is at the beginning od the third days  This means the only 1 and 2 dicember are counted because they are fully included in the dates interval while the 3rd of december is not counted becuse the interval finish at 12:00 AM (beginning of 3rd day) . which date, and time, should i have on the 3rd day, the finishdate, to have it counted on duration?


Hope to be clear,

thank You

Best regards


 



3 Replies

VR Vignesh Ramesh Syncfusion Team November 22, 2021 11:58 AM UTC

Hi marco del frate, 

Greetings from Syncfusion. 

We have analyzed your query and would like to inform you that, the duration is a TimeSpan type property. So, it holds an accurate difference value of Start and Finish date as Duration. If you need to add a day to it, you should provide a complete day (next day’s 12AM) as a finish date. By setting the ShowDateWithTime of property as true, you can see the Hours and Minutes information in GanttGrid. It will give you a better understanding of it.  Please find the snippet below 

XAML: 
<Window.DataContext> 
    <local:ViewModel /> 
</Window.DataContext> 
 
<Grid> 
    <gantt:GanttControl x:Name="gantt" 
                        ShowDateWithTime="True" 
                        ItemsSource="{Binding TaskDetails}" /> 
</Grid> 

[C#]: 
TaskDetails = New ObservableCollection(Of TaskDetails)() 
TaskDetails.Add(New TaskDetails With { 
    .TaskId = 1, 
    .TaskName = "Task 1", 
    .StartDate = New DateTime(2021, 12, 1), 
    .FinishDate = New DateTime(2021, 12, 4) 
}) 

Output: 
 

Please find the sample from the below link. 

Please let us know if you need any further assistance. 

Regards, 
Vignesh Ramesh.


MD marco del frate replied to Vignesh Ramesh November 23, 2021 11:06 AM UTC

Thank You for Your answer.

Your sample is clear to me. What i would need instead is that when i set the same dates You set, the duration shown is 4 days because i want that all the days are fully counted : I have 1, 2, 3, and 4th of december, thus 4 days, not 3. I tried to set the finish date at the 23:59 of the 4th december but, depending on the value of ShowDateandtime property, the duration is 3 days or 3 days and 23 hours and 59 minutes.

is something similar You can see here

https://help.syncfusion.com/angular/gantt/how-to/duration-round-off

but i can0t find in WPF Gantt

 I guess i have to add a custom property to show what i need but it seems to me quite diffulcult because of the week end and holydays.

Thank You





VR Vignesh Ramesh Syncfusion Team November 23, 2021 02:32 PM UTC

Hi marco del frate, 

Thanks for your reply. 

As we have mentioned in our previous update, in our current implementation the duration is a TimeSpan type property, and it holds an accurate difference value of Start and Finish date as Duration. Also, your guess is correct. We must stop the default duration calculation at the source level by setting the UseAutoUpdateHierarchy property of GanttControl as false and defining your own logic (along with considering the holidays, weekends) in the CustomModel’s property. 

NOTE: While disabling the UseAutoUpdateHeirarchy property, then the parent data updating logic also gets stopped. So, we need to update the parent as well. 

Please refer the below User Guide links to know more details  

Regards, 
Vignesh Ramesh.

Loader.
Up arrow icon