truncate date not time

buckwheat

New Member
Joined
Feb 20, 2003
Messages
21
I have a database that pulls in actual trailer arrivals as a date/time value. I also have a table that has the scheduled arrival time by just the time of day without a date. I need to calculate how late the trailer arrivals are. Is there a way to truncate the date and just calculate the time? Example

Field A
11/02/2005 13:00
Field B
12:00

Field A - B should result in 1:00

I would also like to display Field A as 13:00

Thanks in advance.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
try

SELECT timevalue(format(hour([fieldA]),"00") & ":" & format(minute([fielda]),"00")) as ActualArrival, [your planned arrival field] as PlannedArrival, (datediff("h",[ActualArrival],[PlannedArrival])) as TimeDiff
FROM yourtable
 
Upvote 0
Thank you so much, this worked perfect. I am an operation manager and I am self tought access so I struggle with it. This worked perfrect.
Christina
Jax Fl
 
Upvote 0
Another problem: I know have the the actual time displayed seperate as 7:10:00 am but the table I am calculating it against is in this format for example 6:50 is in the field as 6.83 I need to subtract one from the other to get the difference. Any ideas?
 
Upvote 0

Forum statistics

Threads
1,225,845
Messages
6,187,359
Members
453,420
Latest member
ESCH1021

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top