How to calculate the difference between two dates (time elapsed between two program starts) 
Author Message
 How to calculate the difference between two dates (time elapsed between two program starts)

I'd like to know the time elapsed between the last and the next start of
my program.

If I start my program I'd like to save the date and time in a file so
the next time I start the program again I can calculate the time elapsed
since the last program start.
But how can I calculate the difference?

If I store TIMER I can calculated the seconds elapsed since the last
start if you start the program within the same day but how can I
calculate the difference if you restart the program several days later?

Any help and information are very appreciated
Stefan



Sat, 17 Jul 2004 05:14:38 GMT  
 How to calculate the difference between two dates (time elapsed between two program starts)
The DateDiff function alows you to find the difference between dates and/or
times in whatever units you specify


Quote:
> I'd like to know the time elapsed between the last and the next start of
> my program.

> If I start my program I'd like to save the date and time in a file so
> the next time I start the program again I can calculate the time elapsed
> since the last program start.
> But how can I calculate the difference?

> If I store TIMER I can calculated the seconds elapsed since the last
> start if you start the program within the same day but how can I
> calculate the difference if you restart the program several days later?

> Any help and information are very appreciated
> Stefan



Sat, 17 Jul 2004 05:22:24 GMT  
 How to calculate the difference between two dates (time elapsed between two program starts)
save the value from the Now function which is a serial number and then
simply show the difference formatted like Format$(diff#,"dd/mm/yyyy
hh:mm:ss")



Quote:
> I'd like to know the time elapsed between the last and the next start of
> my program.

> If I start my program I'd like to save the date and time in a file so
> the next time I start the program again I can calculate the time elapsed
> since the last program start.
> But how can I calculate the difference?

> If I store TIMER I can calculated the seconds elapsed since the last
> start if you start the program within the same day but how can I
> calculate the difference if you restart the program several days later?

> Any help and information are very appreciated
> Stefan



Sat, 17 Jul 2004 05:56:43 GMT  
 How to calculate the difference between two dates (time elapsed between two program starts)
On Mon, 28 Jan 2002 22:14:38 +0100, Stefan Mueller

Quote:

>I'd like to know the time elapsed between the last and the next start of
>my program.

>If I start my program I'd like to save the date and time in a file so
>the next time I start the program again I can calculate the time elapsed
>since the last program start.
>But how can I calculate the difference?

>If I store TIMER I can calculated the seconds elapsed since the last
>start if you start the program within the same day but how can I
>calculate the difference if you restart the program several days later?

You want this NOW, or is it Now that you want ? :-)

Untested aircode.

Form_Load()
        dim dLast  As Date
        dim fno as Integer
        fno  = freefile
        open app.path & "\logfile.bin" for binary as fno
                get #fno,, dLast
        Close fno
        msgbox("It's been " & DateDiff("s", dLast, Now) & " seconds")
End Sub

Form_QueryUnload()
        dim dNow  As Date
        fno  = freefile
        dNow = Now
        open app.path & "\logfile.bin" for binary as fno
                put #fno,, dNow
        Close fno
End Sub

Working out minutes and hours from seconds is trivial.
The code above should live in separate subs really, it's no good to
clutter either of those events with code like this, but that's just
personal pref..  

Regards, Frank



Sat, 17 Jul 2004 06:01:20 GMT  
 How to calculate the difference between two dates (time elapsed between two program starts)
Great, DATEDIFF is what I was looking for.

Thanks a lot for all your help. I appreciate it very much.
Stefan

Quote:

> On Mon, 28 Jan 2002 22:14:38 +0100, Stefan Mueller

> >I'd like to know the time elapsed between the last and the next start of
> >my program.

> >If I start my program I'd like to save the date and time in a file so
> >the next time I start the program again I can calculate the time elapsed
> >since the last program start.
> >But how can I calculate the difference?

> >If I store TIMER I can calculated the seconds elapsed since the last
> >start if you start the program within the same day but how can I
> >calculate the difference if you restart the program several days later?

> You want this NOW, or is it Now that you want ? :-)

> Untested aircode.

> Form_Load()
>         dim dLast  As Date
>         dim fno as Integer
>         fno  = freefile
>         open app.path & "\logfile.bin" for binary as fno
>                 get #fno,, dLast
>         Close fno
>         msgbox("It's been " & DateDiff("s", dLast, Now) & " seconds")
> End Sub

> Form_QueryUnload()
>         dim dNow  As Date
>         fno  = freefile
>         dNow = Now
>         open app.path & "\logfile.bin" for binary as fno
>                 put #fno,, dNow
>         Close fno
> End Sub

> Working out minutes and hours from seconds is trivial.
> The code above should live in separate subs really, it's no good to
> clutter either of those events with code like this, but that's just
> personal pref..

> Regards, Frank



Sat, 17 Jul 2004 23:00:01 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Calculating the difference between two times and dates with VB

2. Elapsed Time between two dates and times

3. Daylight Saving Time and computing difference between two dates

4. VBScript for calculating difference between two timestamps?

5. Date/Time picker and calculating date differences

6. How to: Calculate # weekdays between two dates...excluding weekends

7. difference between two dates ,in years,months,and days

8. Difference between two dates

9. Difference Between Two Dates - Including Holidays

10. Difference between two dates gives bad results

11. Calculating two times

12. Difference between two dates

 

 
Powered by phpBB® Forum Software