0

I would like to be able to find find the difference between an employee's join date and today. Here is my C# code:

    DateTime JoinDate = Convert.ToDateTime(TextBox1.Text );
    DateTime TodayData = DateTime.Now;
    TimeSpan servicePeriod = TodayData - JoinDate;
    Response .Write ( servicePeriod);

It gives an incorrect answer:

1.11:52:52.6477489 

The format of TextBox1.Text is MM/dd/yyyy.

I want the output in Years, Months and Days.

Pradnya Bolli
  • 1,915
  • 1
  • 19
  • 37

1 Answers1

0

You need to change it to:

TimeSpan servicePeriod = TodayData.Subrtact(JoinDate);
israel altar
  • 1,768
  • 1
  • 16
  • 24