© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
130 replies
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;
}
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
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

✅ Converting string to DateTimeOffset
C#CC# / help
2y ago
❔ error when converting string to long
C#CC# / help
3y ago