Subtracting two times

# Thread: Subtracting two times

1. Senior Member
Join Date
Dec 1969
Posts
177

## Subtracting two times

Any way to subtract times without using the datediff function? The datediff will only allow me to get the difference of two times by minute or second or hour, etc...<BR><BR>I need the difference in two times that will show the difference in minutes and seconds.<BR><BR>Ex. 2:04 - 2:54 = :50<BR> 3:55 - 5:54 = 1:59<BR><BR>Any way to achieve this with some other asp function I am not aware of?

2. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## R&D DateDiff function <eop>

.

3. Senior Member
Join Date
Dec 1969
Posts
1,570

## build a function...

I don&#039;t know if there is something out there to do this for you, but you could take the the two times and translate them into seconds and subtract that way... ie:<BR><BR>2:04 = 7440 seconds<BR>2:54 = 10440 seconds<BR><BR>7440 - 10440 = 3000 / 60 = 50 minutes (translate this back into a time, or :50)<BR><BR>I don&#039;t know if this is a very effective way, but it would work with a simple math function!!!

4. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## To answer your question

&#062;I don&#039;t know if this is a very effective way<BR>No it is not<BR><BR>

5. Senior Member
Join Date
Dec 1969
Posts
1,570

## it would work...

just an idea there buddy...

6. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## Never said it would not

just saying it will be a waste of time and will obviously be slower "buddy"<BR><BR><BR>

7. Senior Member
Join Date
Dec 1969
Posts
2,334

## RE: II would have done the same...

If I had the same problem, I would use split to get minutes and seconds and then use some maths to get the total number of seconds and then convert them back to the minute:second value.

8. Senior Member
Join Date
Dec 1969
Posts
1,570

## hahah...

I know. Just trying to get up under your skin...! Not a hard thing to do.<BR><BR>have a good one!

9. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## instead of using the built in function??

wow....what i am more impressed about is that you would actually admit it :)<BR><BR>

10. Senior Member
Join Date
Dec 1969
Posts
2,334

## RE: Since DateDiff won't give us..

the solution right there in one line so this was the other option which quicky comes to mind. It can be accomplished by writing 4-5 lines of code.<BR><BR>How much inefficient would you say it is...compared to the other solution which you recommend...Curiosity!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•