Topic: count working times and overtimes

Hi guys
I need help with my project.
there are 3 workers in a company and each one has to work 7 hours a day.
in my project I need to count the hours that they work. for example if Tom arrives at 8:00 A.M and leaves at 5:30 P.M, then the project says that Tom worked 7 hours plus 2:30 hours of overtime. and at the end of the month count all the hours and overtimes separately.
thanks a lot

Re: count working times and overtimes

And where is the project with which you need help?

Re: count working times and overtimes

Hi
This is my project
I have some major problems:

1- in the Form 3 I need the project to calculate the time of work automatically.
for example if a person works from 8:00 to 16:30. in the Form3 the total time should be 8 hours and 30 seconds

2- in the Form 3 the overtime should be calculated like this:
Total time minus 8 = Overtime

3- in the Form 1 when I search a person between two dates for example between 1st of July and 30th of July, in the TableGrid1, the total work and overtime of that person should be calculated automatically

is this possible?

thanks a lot for helping me out guys

Post's attachments

Attachment icon WorkHours.zip 336.79 kb, 117 downloads since 2023-01-05 

Re: count working times and overtimes

Here is an example.
I think that it will not be difficult for you to do by analogy for overtime.

Question 3 a little later.

Post's attachments

Attachment icon WorkHours1.zip 337.74 kb, 137 downloads since 2023-01-05 

5 (edited by sparrow 2023-01-05 13:50:58)

Re: count working times and overtimes

in the Form 1 show only work time and overtime. Total time is SUM of work and overtime.
You will complete the search on Form1 yourself.


I think that you can do question 2 yourself. Similarly.

Post's attachments

Attachment icon WorkHours2.zip 337.97 kb, 125 downloads since 2023-01-05 

Re: count working times and overtimes

Thanks so much sparrow
You Rock

The first part ( Counting between two hours) works perfect.

unfortunately in the Form1 when you add a new person total work time and total over work are not correct.
I have attached this project with two workers, could you please take a look and see what's wrong with TableGrid1 in Form1 ?

I changed it a little bit, I guess I can count overtime myself so I removed the overtime (But I don't know how to change the calculated field for the "work time" in the table "timetable")  instead I add months of the year.
what I need to do is that the total working time in the Form2 for each month is calculated and shown on the textboxes?

if this can be done, most of my problems will be solved.

Post's attachments

Attachment icon WorkHours3.zip 341.94 kb, 113 downloads since 2023-01-05 

Re: count working times and overtimes

Hi Identity, Hi Sparrow,
There are a number of ways to approach this - have a look at the attachment which might give you some ideas.
At the moment, it doesn't attempt to calculate the elapsed time if the 'finish time' goes past midnight (but it's a simple modification);  I didn't put it in because I didn't know if it's a requirement for your project or not.
Hope this helps,
Derek.

Post's attachments

Attachment icon overtime.zip 343.07 kb, 146 downloads since 2023-01-05 

8 (edited by sparrow 2023-01-05 22:04:51)

Re: count working times and overtimes

Hi Derek, Interesting solution.


Identity,
Fix TableGrid1 on Form1. Modify table Jan, Febr, Mar. on Form2.

Post's attachments

Attachment icon WorkHours3-upd.zip 340.98 kb, 126 downloads since 2023-01-05 

Re: count working times and overtimes

Thank you Derek and Sparrow
Derek your sample gave me some good ideas for my project. thanks a lot

Sparrow your sample works fine and lot of thanks to you, but when I add a new person, I get error.
another important thing is that is there anyway that the total work time for each month is shown in the  Panel1 - Form2 ?
thanks guys. your help means a lot to me.

10 (edited by sparrow 2023-01-06 09:22:10)

Re: count working times and overtimes

fix edit records Auto update month work time

Post's attachments

Attachment icon WorkHours4-fix.zip 343.26 kb, 140 downloads since 2023-01-06 

Re: count working times and overtimes

Hi Everyone
thank you sparrow . your project works great as always.
there is only one problem though. In my own project I can't use Gregorian Calendar so I need a second approach for these kinds of problems.
the only way that I can think of is to use 3 Textboxes for year, month and day in which I insert a date myself.
for example for  the first textbox I type 2023 and the second textbox is 01 for the month of September and the third textbox is the day.
I have attached Sparrow's last sample and I have replaced the DateTimePicker2 in Form3 with my own approach for the date part.
Is it possible to use this kind of approach for date and how it can be used?
Please Check the script and renew it based on my suggestion if it is possible
thank you all

Post's attachments

Attachment icon WorkHours5.zip 343.94 kb, 111 downloads since 2023-01-09 

Re: count working times and overtimes

I think that you are able to do it yourself, for this you have everything.
As for the DateTimePicker, I advise you to pay attention to http://myvisualdatabase.com/help_en/propertyFormat.html.
This will allow you to use the date display however you like.

Re: count working times and overtimes

Hi sparrow
you didn't get what I meant
As far as I know there are many calendars and most of the countries use Gregorian calendar but in my country we use Persian Calendar which is not supported in this version of software.
I can't use Datetimepicker because our year is different from yours and when I enter our solar year into the datetimepicker, it is converted to the Gregorian year. I paid  attention to the example you gave but that can not solve this problem.
I think the only solution is the one I suggested.
I'd be grateful if you could help me with my project.

14 (edited by sparrow 2023-01-09 10:54:55)

Re: count working times and overtimes

This doesn't change my answer.
You have everything to solve this problem.

I didn't see any attempt on your part to do anything yourself.

I myself know how to draw fields, inscriptions and set tasks for others.
I can help, but I can't do it for you.

Re: count working times and overtimes

Fine
Don't help me
But know this, I have read all of the parts of  ' property Format ' and tutorials in the site for hours and I have attempted a lot but I cant make head or tail of Gregorian Calendar at all. Changing this Calendar to suit my purpose is beyond me.

Re: count working times and overtimes

Three butterflies, flying up to a burning candle, began to talk about the nature of fire. One flew up to the flame, returned and said:

- The fire is shining.

Another flew closer and scorched the wing. Arriving back, she said:

- He's stinging!

The third, flying very close, disappeared in the fire and did not return. She learned what she wanted to know, but was no longer
able to tell the rest about it.

The one who has received knowledge is deprived of the opportunity to speak about it, therefore the one who knows is silent,
and the one who speaks does not know.

Re: count working times and overtimes

http://myvisualdatabase.com/forum/viewt … 834#p43834

Визуальное программирование: блог и телеграм-канал.

Re: count working times and overtimes

Thank you Sparrow for the nice story smile
I studied the tutorials once again and eventually fixed the problem by using "dd MM yyyy" for the format in the property field of the DateTimePicker2 in the Form3.
the only problem is that the start year in this version of software is 1601 and you can't enter a year before 1601.
Our year is 1401 so As soon as I enter a year it is converted to 2023.
Is there a way to prevent the date to convert automatically?
AND This is my   smile LLLAAASSSTTT  smile question
thanks

Post's attachments

Attachment icon WorkHours6.zip 343.06 kb, 129 downloads since 2023-01-10 

19 (edited by sparrow 2023-01-10 09:25:58)

Re: count working times and overtimes

You can use one of the following solutions.
1. You can try to set your computer's regional settings to Persian. This will convert the calendar to Persian chronology in the computer and program.
2. However, you can leave as you did earlier and enter the date by hand in the boxes year - month - day separately.
And combine them ( 'string1' || '-' || 'string2' || '-' || 'string3' ) when outputting to another box.
3.Also in SQLite you can use the strftime('%s', '1041-10-10') function to encode dates
and decode it on output strftime('%Y-%d-%m', your date column, 'unixepoch').


For options 2 and 3, you need to familiarize yourself with working with time and strings in SQLite)))
Options 2, 3 have already been partially used in my time coding examples, so I indicated earlier that you have everything to solve the problem.

Re: count working times and overtimes

Hi Sparrow
is there anyway that in Form1 and Form2 instead of using a textbox for the name of the driver, we use a Combobox ?
And When you select a Driver in the Form2 Combobox1 all the Work Hours of that Driver are updated automatically in the Fom2 Textbox2 to13 .
What I mean is that as you can see in the attached project, there are 2 drivers with the same name

Post's attachments

Attachment icon WorkHours6.zip 344.27 kb, 115 downloads since 2023-01-29 

21 (edited by sparrow 2023-01-30 05:40:41)

Re: count working times and overtimes

Can simplify?
It will be very good if you write for yourself what you want from your program.
What data, in what form, on what form do you want to see, etc. ...

Project in the next post

Re: count working times and overtimes

Fixed bug with time calculation.
Added footer total in the table.

Post's attachments

Attachment icon WorkHours8-fix.zip 15.61 kb, 132 downloads since 2023-01-29 

23 (edited by identity 2023-02-08 15:38:58)

Re: count working times and overtimes

Hi Sparrow
in the project  that you attached, Form2 Button CbMonth shows all the name of the months automatically.
How can I change the name of a month (for example use " 1 " instead of January or " 2 " instead of Feurary) or delete a month?
thanks

Re: count working times and overtimes

On Form2.cbmonth use 'ID' instead of 'mnth'.
Why would you want to delete a month?

25 (edited by sparrow 2023-02-08 21:22:32)

Re: count working times and overtimes

Hello Derek. Thank you.

Hi identity,
1. If you need numbers, take Derek's advice. In the CbMonth properties, in the FieldName field manually enter "id", without quotes.
2. If you need to change the name of the month, you can temporarily create a form to edit the month.
3. If you are familiar with SQLite database manager software, you can change directly in the database.