Date Calculation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Ok, I've looked around for the answer, but all I'm getting is frustrated.
Someone please help this poor soul.

In my query, I have [PU Date Time] and [Arrival Date Time]. I need to
calculate the hours in between and populate that in [Variance].

For instance.
[PU Date Time] = 7/15/06 3:00 PM
[Arrival Date Time] = 7/15/06 5:30 PM

I need my expression field to say simply "2.5". If it were negative, I
would need it to say "-2.5".
 
Chuck

Take a look at the syntax for DateDiff() in Access HELP.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Ok, I've looked around for the answer, but all I'm getting is frustrated.
Someone please help this poor soul.

In my query, I have [PU Date Time] and [Arrival Date Time]. I need to
calculate the hours in between and populate that in [Variance].

For instance.
[PU Date Time] = 7/15/06 3:00 PM
[Arrival Date Time] = 7/15/06 5:30 PM

I need my expression field to say simply "2.5". If it were negative, I
would need it to say "-2.5".

In a query?
Variance: DateDiff("n",[PU Date Time],[Arrival Date Time])/60

Note: This value should NOT be stored in any table.
Whenever you need to result of the calculation, re-calculate it, as
above.
 
Ok, I've looked around for the answer, but all I'm getting is frustrated.
Someone please help this poor soul.

In my query, I have [PU Date Time] and [Arrival Date Time]. I need to
calculate the hours in between and populate that in [Variance].

For instance.
[PU Date Time] = 7/15/06 3:00 PM
[Arrival Date Time] = 7/15/06 5:30 PM

I need my expression field to say simply "2.5". If it were negative, I
would need it to say "-2.5".

The DateDiff() function calculates the difference in time between two
date/time values. I'd suggest calculating the time in minutes and
dividing by 60 to get fractional hours:

Variance: DateDiff("n", [PU Date Time], [Arrival Date Time]) / 60.

Note that Variance should be calculated as needed, and should NOT be
stored in any Table field.

John W. Vinson[MVP]
 
That did the trick....thanks!!!

John Vinson said:
Ok, I've looked around for the answer, but all I'm getting is frustrated.
Someone please help this poor soul.

In my query, I have [PU Date Time] and [Arrival Date Time]. I need to
calculate the hours in between and populate that in [Variance].

For instance.
[PU Date Time] = 7/15/06 3:00 PM
[Arrival Date Time] = 7/15/06 5:30 PM

I need my expression field to say simply "2.5". If it were negative, I
would need it to say "-2.5".

The DateDiff() function calculates the difference in time between two
date/time values. I'd suggest calculating the time in minutes and
dividing by 60 to get fractional hours:

Variance: DateDiff("n", [PU Date Time], [Arrival Date Time]) / 60.

Note that Variance should be calculated as needed, and should NOT be
stored in any Table field.

John W. Vinson[MVP]
 
Back
Top