TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kedar Pawgi
1.6k
136
63.4k
How to get Hours worked by employee using
May 14 2020 6:59 AM
Hi i would like to calculate working hours by employee.
I have 3 text boxes txtMorningInTime,txtMorningOutTime,txtMorningTotHrs
I will enter logged in time , logged out time and then i should get the correct working hours. By viewing some links here i tried but its not working. i am using following code suggested by some one here on C# Corner
DateTime loggedIn = Convert.ToDateTime(txtMorningInTime.Text);
DateTime loggedOut = Convert.ToDateTime(txtMorningOutTime.Text);
TimeSpan totHrs = loggedIn - loggedOut;
txtMorningTotalHrs.Text = totHrs.ToString();
But whats happening is ,if i put loggedin time as 10.30(its AM) and logged out time is 2.30 (PM), it should calculate 4 hours.
when i debug its converting the value in txtMorningInTime.text as (30/10/2020) and giving error string was not in correct format for txtMorningOutTime.Text.
what is the solution for this. I need some urgent help. How can i convert the textbox time to time and calculate total working hours.
Thanks In Advance.
Reply
Answers (
2
)
Fetch the data from external API in c#
Windows Form - Can i use SQL ODBC connector