C#C
C#3y ago
Mek

✅ Converting String To DateTimeOffset & Getting Average Days To Goal

public static string? CalculateDaysToGoal(string? startDate, string? endDate, string? hoursPerDay)
{
    DateTimeOffset startDate = DateTimeOffset.Parse(startDate);
    DateTimeOffset endDate = DateTimeOffset.Parse(endDate);
    TimeSpan differenceInDays = endDate.Subtract(startDate);

    string daysToGoal = Math.Ceil(differenceInDays / hoursPerDay).ToString();
    return daysToGoal;
}
I started a new thread as this is a new thing. I need to create a helper function that takes in 3 parameters to calculate the number of days the user needs to spend coding based off the number of hours per day they want to put towards this goal in order to get the number of days it will take them to achieve said goal. I've never done this before, not even in Python, so I have no idea how to start or what to do. Thanks in advance

Edit: I started giving it a shot, and this is where I'm at
Was this page helpful?