DateAdd Assistance

BSULLY65

New Member
Joined
Mar 14, 2008
Messages
19
I am writing a report that sums the amount of time a person spend on a function over a period of time. I am using the folling to calculate the sum for month

=Format(DateAdd("n",[txtEmpTotMinutes],#12:00:00 AM#),"hh") & ":" & Format(DateAdd("n",[txtEmpTotMinutes],#12:00:00 AM#),"nn")

txtEmpTotMinutes = the total minutes worked for month (The db stores all time in minutes)

As example one emp. has a total of 10,560 minutes spent but the above function returns 08:00.

What part of dateadd am I missing ?





 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Don't use the DateAdd function.
This returns a date, not the amount of time that has elapsed. Thus when you use this function on 10560 minutes, it returns a date, 7 days and 8 hours later. Since you are adding only the hour component to the time of 12 AM, of course you get 8 AM.

Try this instead:
Code:
= iif(Fix(txtEmpTotMinutes/60) Is Null, 0, Fix(txtEmpTotMinutes/60) & ":" & (txtEmpTotMinutes Mod 60)

By the way, if you are storing date/time values, you can caculate the difference between these date/times, i.e. elapsed time, by using DateDiff function.

Hope this helps
 
Upvote 0
This worked nicely, Thank You ! as for times everything is stored in minutes and gets calulated to hh:mm during queries and/or reports.
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,825
Members
449,096
Latest member
Erald

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