Convert no. of days into year and month

Dear all,

Is there any way or formula that can convert a total no. of days in year and month.

I know that to convert into, just divide it with 365 days, however, there is a problem to convert into month, because no. of days in a month is different. Anybody has any idea about this?

Thanks in advance.

Subject: Convert no. of days into year and month

What about leap years - 366 days? In addition to knowing total number of days, the start date is also required to compute how many months/days are in between.

Or if it just a rough computation you can do like this:

no of months = no of days /(365/12)

Rgds

Litty Joseph

Subject: Convert no. of days into year and month

Take a look at the @adjust function, you will be able to use that to get the results you want.

Subject: RE: Convert no. of days into year and month

Carl’s answer will give you an end date if you have the start date and number of days, or the start date if you have an end date and number of days. I have the feeling, though, that you have both a start and end date and want to get the number of years and months between them – and getting the number of days is a simple matter of subtracting then dividing by the number of seconds in a day.

There’s a bit more to getting the number of months, years and days between dates than subtracting and dividing. Here’s a formula I posted in the R4 & R5 forum in 2003:

startDate := Time1;

endDate := Time2;

startDay := @Day(startDate);

endDay := @Day(endDate);

startMonth := @Month(StartDate);

endMonth := @Month(endDate);

startYear := @Year(startDate);

endYear := @Year(endDate);

lessAYear := @If(endMonth > startMonth;@False; (endMonth = startMonth) & (endDay >= startDay); @False; @True);

yearsDiff := @If(lessAYear; endYear - startYear - 1; endYear - startYear);

@Set(“endDate”; @Adjust(endDate;-yearsDiff;0;0;0;0;0));

monthAdj := @If(startDay>endDay;-1;0);

monthsDiff := @If(lessAYear; (endMonth + 12) - startMonth + monthAdj; endMonth - startMonth + monthAdj);

@Set(“endDate”;@Adjust(endDate;0;-monthsDiff;0;0;0;0));

daysDiff := @Integer((endDate - startDate)/86400);

@Prompt([Ok];“”;@Text(yearsDiff) + “years, " + @Text(monthsDiff) + " months, and " + @Text(daysDiff) + " days.”)

Subject: Yeah, I had assumed the start date was always Jan 1