C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C# program that converts days to months
using System;
class Program
{
static void Main()
{
int days = 200;
// Divide by this constant to convert days to months.
const double daysToMonths = 30.4368499;
{
double months = days / daysToMonths;
Console.WriteLine("{0} days = {1:0.00} months", days, months);
}
}
}
Output
200 days = 6.57 months
However: If you are just in general converting days to months, this is the best way to do it.
Also: Leap years also influence the computation. Ideally the exact date range would be known, so this consideration can be applied.