I am developing web application using C#,ASP.net and ms sql server.
now i have integer input example 402 days.
now i want to express it in years, months and days.
that is
1 year, 1 month and 7 days.
so how can i do this?
thanks
Printable View
I am developing web application using C#,ASP.net and ms sql server.
now i have integer input example 402 days.
now i want to express it in years, months and days.
that is
1 year, 1 month and 7 days.
so how can i do this?
thanks
You can't do it reliably unless you have a reference date, because the same number of total days might represent a different number of years, months and days depending on which months of which years it spans. That's because of leap years and the fact that different months contain different numbers of days.
on sorry. yes i have a reference date.
i have a registration form. it has a column which is dateOfJoining.
example. MR Girmay joined the company in Nov -10-2011 and
now he wants to leave the company after he spend 402 days.
so how do i convert his expedience, in to years and months and days...
thanks
Try this, you just need to add a label to the page.
C# Code:
protected void Page_Load(object sender, EventArgs e) { DateTime d = new DateTime(2011, 10, 11); this.Label1.Text = d.AddDays(402).ToString(); }