Solved

Time difference in seconds

Posted on 2009-04-08
5
486 Views
Last Modified: 2012-05-06
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
Comment
Question by:pvg1975
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 24104636
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")
	
%>

Open in new window

0
 
LVL 12

Accepted Solution

by:
Dimitris earned 500 total points
ID: 24104657
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

by:pvg1975
ID: 31568400
Thanks for the solution!
0
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 24104684
huh.. hmmm
0
 
LVL 12

Expert Comment

by:Dimitris
ID: 24104727
sorry ryancys,
I haven't seen your post because i had the question open
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question