Solved

Time difference in seconds

Posted on 2009-04-08
480 Views
Hello guys,

I am kind of a newbee...

Is there any way to know a time difference in seconds in standard ASP? The time difference will never be more than 100 seconds. I need to know that time difference between 2 times, but the problem I have is when the process runs, for example, from 11:59:25 PM to 00:00:34 AM (for the day change).

Thanks!
0
Question by:pvg1975
• 2
• 2

LVL 49

Expert Comment

try:
``````<%

function getTimeDiff(t1, t2)

if isDate(t1) = false or isDate(t2) = false then

getTimeDiff = "-"

else

dummyToday = DateSerial(2000,1,1)

dummyToday2 = DateSerial(2000,1,2)

d1 = CDate(t1)

d2 = CDate(t2)

if d1 > d2 then

d1 = dummyToday + d1

d2 = dummyToday2 + d2

total = DateDiff("s", d1, dummyToday2) + DateDiff("s", dummyToday2, d2)

else

total = DateDiff("s", d1, d2)

end if

getTimeDiff = total

end if

end function

response.write getTimeDiff("11:59:25 PM", "00:00:34 AM")

%>
``````
0

LVL 12

Accepted Solution

Dimitris earned 500 total points
here you are, you will use datediff

datediff("s","1/1/2009 11:59:25 PM","1/2/2009 00:00:34 AM")

Please keep in mind that my date format is MM/DD/YYYY
0

Author Closing Comment

Thanks for the solution!
0

LVL 49

Expert Comment

huh.. hmmm
0

LVL 12

Expert Comment

sorry ryancys,
0

Featured Post

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…