Topic: Start-stop-elapsed day time

Hi,
How do you in script  with 3 date time picker components Start day time, stop day time and elapsed days time?
Thanks

Re: Start-stop-elapsed day time

Hello,


Unfortunately I don't understand your question, please provide more details, what you need.

Dmitry.

Re: Start-stop-elapsed day time

Hi again,
Maybe there should be 3 timers in script code. Date and start time, Stop time and date and elapsed time and date.
Thanks

Re: Start-stop-elapsed day time

You need to know how many days between two dates?

Dmitry.

Re: Start-stop-elapsed day time

In order to be able to help you we may need more details carlo_dj! Maybe you are trying to achieve something which could be done in a way you did not even expect wink

What do you want to do?

Re: Start-stop-elapsed day time

Hi Dmitry and Tcoton,

Yes, I want try to count the difference between the two dates. Ex. New repair IN date time - repair OUT date time = TOTAL repair spend.
Thanks, Carlo

Re: Start-stop-elapsed day time

I did it in one of my project as SQL Query in a grid to get the elapsed time between 2 dates. The key is

round(julianday('now')) -round(julianday(return_date)) as 'Days Count'
select
a.PCName as "PC Name",
b.Type as "Model",
c.IMG as "Connect",
strftime("%d.%m.%Y" , Return_date) as "Return Date",
a.Remarks as "Remark",
a.BIOSpwd as "BIOS Pwd",
e.UserID as "User ID",
round(julianday('now')) -round(julianday(return_date)) as 'Days Count'
from computers a

left join Pc_typ b on b.id=a.id_pc_typ
left join conn_img c on c.id=a.id_Conn_img
left join status d on d.id=a.id_Status
left join users e on e.id=a.id_Users
where a.id_Status=4
and Return_date in
(SELECT return_date FROM computers
WHERE (julianday('now') - julianday(return_date))
between 0 and (select quarantine from parameters) )

Re: Start-stop-elapsed day time

Hello Carlo, Thierry, Dmitry,
I did a similar small project a while ago (with the help of some code from Mathias). 
I have changed my project a bit to show elapsed hours as well as days and have attached it for you to have a look at.
I added a few rows of sample data and it still seems to be working but haven't put any error checking in place (for example - is the end date before the start date etc etc) but that wasn't your question.
I hope this helps you,
Derek.

Post's attachments

Attachment icon carlodj.zip 339.16 kb, 619 downloads since 2016-01-19 

Re: Start-stop-elapsed day time

Nice scripts smile

Re: Start-stop-elapsed day time

carlo_dj wrote:

Hi Dmitry and Tcoton,

Yes, I want try to count the difference between the two dates. Ex. New repair IN date time - repair OUT date time = TOTAL repair spend.
Thanks, Carlo

Where you need to see result? In a TableGrid or in a TextBox?
Because if you need result in a TableGrid, you should using calculated field, if result should be in  a TextBox, you should use a script.

Dmitry.

Re: Start-stop-elapsed day time

I did not even thought about a calculated field... thanks Dmitry. Do you have a quick example?

Re: Start-stop-elapsed day time

tcoton wrote:

I did not even thought about a calculated field... thanks Dmitry. Do you have a quick example?

julianday(datefield1) - julianday(datefield2)
Dmitry.

Re: Start-stop-elapsed day time

Hi best MVD friends,

Thanks for the quick response and the script solutions. Dmitry, I thought about to use it in a table and a form. So for the table with calculated field and with script to see the result in a textbox. Now I to think about how I best the script intrigue in my project. Thanks again all. With best regards. Carlo

Re: Start-stop-elapsed day time

carlo_dj
I made an example for you:

Post's attachments

Attachment icon Days between dates.zip 4.86 kb, 647 downloads since 2016-01-20 

Dmitry.

15 (edited by ngdbjl07 2021-07-08 15:21:15)

Re: Start-stop-elapsed day time

plz i need help how to add days to date exmp in zz.png

Post's attachments

Attachment icon zz.PNG 10.5 kb, 117 downloads since 2021-07-08 

Re: Start-stop-elapsed day time

Try this
Form1.datetimepicker2.datetime := form1.datetimepicker1.datetime + (form1.edit1.value);// +1 means 1 day