0
votes

I have a table name timelogTB and it has 5 column named; LogID(PK), EmpNo(FK), Time_In, Time_Out and Date running in form1.

Then in form2 I have a combobox where the Employee # of an employee can be selected and when I will select an Employee # the total number of hours worked of that employee will display in a textbox.

I have two date time picker the dtpicker1 is labeled dtpFrom and dtpicker2 is labeled dtpTo.

The column Time_In and Time_Out in timelogTB is only recording the time in military standard when the employee is time in using also a date time picker.

I am looking forward for a favorable answer guys, as much as possible I want you to explain it more simpler and precise because I am new in vb.net

thanks in advance!

1
By "military standard", do you mean like "13:30:00.000" or "1330"? If the former, you'd simply sum the DATEDIFF of the time_in and time_out (with a WHERE clause if you require it for a certain date period). e.g. select sum(datediff(second, time_in, time_out) / 60.0 / 60.0) from mytable /* where date between myfirstdate and my second date */. If the latter, you'd need to convert the values to TIME first (e.g. cast(left(time_in, 2) + ':' + right(time_in, 2) as time(0))) then do the same thing.ZLK
@ZLK yes its the 1st one. Thank you very much, I will give it a try.AtanHokage04
@ZLK, I have also the same problem with another code, this time its about total days worked.AtanHokage04
Days would be a count of the distinct dates in the table. e.g. select count(distinct date) from mytable /* where empno = abc and date between date1 and date2 */ZLK
@ZLK, thank you very much sir. I will try this code and I hope when I'll ask again you will answer me again in short time. Thank you again and more power.AtanHokage04

1 Answers

0
votes

It sounds like you're looking for the DATEDIFF function. Now just find a way to plug in your variables.