Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subtracting two times.

Status
Not open for further replies.

djmc

Programmer
Jun 12, 2002
179
0
0
CA
Let's say I have some data I parsed. And the time format is the following:

hh:mm:ss (24hr format)

i.e 15:13:09

I want to subtract the two times and get an overall duration value.

i.e 10:00:00 - 9:30:00 = 00:30:00

or something of that nature.. thanks.
 
Hi,

If your times are in A1 and B1, then the difference is
[tt]
=B1-A1
[/tt]
formatted [h]:mm:ss

Skip,
[sub]
[red]Be advised:[/red] [glasses]
Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue][/sub]
 
I just found out that I could utilize DateDiff(), DateAdd()
however I want to know how to add days as well..

i.e Sat + 1 -> Sun, Sun + 2 -> Tue

Thanks.
 
Dates are just numbers. like today is 38224.

So you just ADD days to you date
Code:
MyDate = Date
MyDate = MyDate + 7
is wednesday september 1, 2004

Skip,
[sub]
[red]Be advised:[/red] [glasses]
Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue][/sub]
 
Hi djmc,

Skip is correct (of course [smile]) but what App are we talking here, Excel or Access? And where in the app are your dates - in a worksheet cell, in a table field, in a VBA variable?

If the simple addition doesn't cut it, why not look at the Help for DateAdd - you can specify the units, and positive or negative quantities.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
I often use YEAR(B12)-YEAR(C12), then just format the cell that you are displaying the result as a number.

Hope it helps!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top