Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have an employee in my website,and i have start date and end date in my database.Now, how to show time duration for example

EMPLOYEE
Madhu Gadhe(total period 4 Years 2014-2018)
Start Date: 12/6/2014 9:00 AM
he worked 6 months 18 days 12 hours 30 minutes 30 seconds
remaining 3 years 6 months 18 days 12 hours 30 minutes 30 seconds

i want to show like this
Posted

1 solution

you can simply subtract two datetimes and get TimeSpan as below
C#
TimeSpan worked = today- startdate;

TimeSpan remaining = enddate -today;

then using TimeSpan properties[^] you can diplay what you want
note that, you can get current date time using DateTime.Now Property[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900