Time Difference

W

WSF

Access97

I wish to:
1 - hold a FirstQryTime (not date/time - just the time) when a data
query [Qry1] is run and hold that time as a reference for the duration of
the current session, without having to write it to a table.

I then wish to calculate the time difference in minutes between that time
and a second query [Qry2] being run - say SecondQryTime.

2 - If the second query is run before the first (that implies the
FirstQryTime is "" or Null or 0 ?) I want to present a MsgBox to the
operator and exit the routine.

I have tried several ways of doing it but get stuck on data types, and have
also ended up with a 6 - Overflow error message (2 above).

Seems simple but I can't get my head around it.

TIA
WSF
 
R

Rod Scoullar

If you use a global variable, gdatFirstQryTime and initialise it to 0 then
give it the value Now() when the first query is run

Before running the second query test to see if gdatFirstQryTime=0 if it does
display the message box etc.

If it is not then the first query has been run.

You can calculate the time since the first query was run using the DateDiff
function. I keep forgetting which positions the times go but for minutes
use DateDiff("n",gdatFirstQryTime,Now()). If it is a negative value switch
the time positions.

Rod Scoullar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top