Help with calculating dates

  • Thread starter Thread starter Robert Pitchford
  • Start date Start date
R

Robert Pitchford

I am trying to program my main form to display a warning
message. That when a new record is created, will search
another table to see if the same type of record was
created less than 24 hours ago.
i.e.) Hertz uses Access 2000 as a ticketing system to
track trouble throughout their global network. When a new
ticket is created. I would like to see how i would go
about checking whether a previous ticket has been
opened/closed within a 24 hour time frame.
I am stuck on how to approach the calculation of the 2
dates to see if the closed ticket is less than 24 hours
older than the new ticket.

Can anyone help me?
 
Lookup DateDiff in the help files. It will look something
like this:

Dim datNewDate As Date
Dim datOldDate As Date
Dim intIntervalsBetween As Integer
datNewDate = "7 july, 2003 16:30:00"
datOldDate = "7 july, 2003 14:30:00"
intIntervalsBetween = DateDiff("h", datNewDate, datOldDate)

Hint:
You may want to get the difference in minutes ("n") then
divide by 60 if you want to be more precise. Difference in
hours will round up/down and may not be 100% accurate. It
depends on how specific you want to be.
-Cameron Sutherland
 
Robert

Use the DateDiff function;

intHours = DateDiff("h", EarliestDateTime, LatestDateTime)

HTH

Andy
 
I am stuck on how to approach the calculation of the 2
dates to see if the closed ticket is less than 24 hours
older than the new ticket.

The DateAdd function is the ticket here. A query with a criterion on
the TicketTime field of
DateAdd("h", -24, Now())

will find all records with TicketTime during the 24 hours before the
query is run.
 
Back
Top