GetWorkingHours

GetWorkingHours(DateTime, DateTime)

Return working hours for the specified dates.

public WorkUnit GetWorkingHours(DateTime start, DateTime finish)
ParameterTypeDescription
startDateTimeStart date.
finishDateTimeFinish date.

Return Value

Working hours.

Examples

Shows how to get working hours for specific dates.

var project = new Project(DataDir + "Project1.mpp");

var calendar = project.Calendars.GetByUid(1);

// get working hours for specific date
var workUnit = calendar.GetWorkingHours(new DateTime(2020, 4, 8, 8, 0, 0), new DateTime(2020, 4, 9, 17, 0, 0));

// 16 hours will be printed
Console.WriteLine(workUnit.WorkingHours);

See Also


GetWorkingHours(DateTime)

Returns amount of working hours at the date.

public TimeSpan GetWorkingHours(DateTime dt)
ParameterTypeDescription
dtDateTimeThe date to get working hours for.

Return Value

Working hours.

Examples

Shows how to get working hours for a specific date.

var project = new Project(DataDir + "Project1.mpp");

var calendar = project.Calendars.GetByUid(1);

// get working hours for specific date
var workingHours = calendar.GetWorkingHours(new DateTime(2020, 4, 10));

// 8 hours will be printed
Console.WriteLine(workingHours.Hours);

See Also