Subtracting Hours in Query

rastus

Board Regular
Joined
Jul 8, 2005
Messages
157
Hi

I have a query with two calculated fields that return the business hours between two sets of dates in the format "h:nn".

What I would like to do is subtract the first field [HoursA] from the second [HoursB], but the expression [HoursA] - [HoursB] doesn't work like it would in excel. I have also tried DateDiff("n", [HoursA], [HoursB]), but this only works if either field is less than 24 hours.

Does anyone have a expression for subtracting these calculated fields e.g. 20:00 - 5:00 = 15:00 hours?

Regards
R
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi Steve, How are you? I did a test here that just as you quoted, calculated fields in the query subtracting one hour from another, on principle did not work, as if the values ​​were divided by one hundred, to solve I put the format of the fields in the query as "h: nn", you tried it?
 
Upvote 0
If your fields are true dates you should be able to add/subtract directly. Is the result of your query a true time in time format, or is it a text string that represents a time? When you say it doesn't work, what is the error or problem you are getting?
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,449
Members
449,083
Latest member
Ava19

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