• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 490
  • Last Modified:

Time difference in seconds

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).

  • 2
  • 2
1 Solution
Ryan ChongCommented:
	function getTimeDiff(t1, t2)
		if isDate(t1) = false or isDate(t2) = false then
			getTimeDiff = "-"
			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)
				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

DimitrisSenior Solution ArchitectCommented:
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
pvg1975Author Commented:
Thanks for the solution!
Ryan ChongCommented:
huh.. hmmm
DimitrisSenior Solution ArchitectCommented:
sorry ryancys,
I haven't seen your post because i had the question open
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now