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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp time diff 1

Status
Not open for further replies.

hz

Programmer
Oct 2, 2000
29
US
I know there is a datediff() function to calculate the time different between different days. Is there a way to calculate the time difference between the same date?
 
Thanks for the reply, I am not too sure about what you mean, could you plz give a code example?
 
DateDiff can calculate between times as well. The function name can be confusing, but it is referring to Date objects (which include times) just not dates.

Anyway, you can do this:

DateDiff(interval,date1,date2)

Intervals can be any of the following:

Setting Description
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week of year
h Hour
n Minute
s Second

To calculate times, date1 and date2 need to be VB/VBScript date variable types.

Hope this clarifies for you. Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
DateDiff doesn't work for me...
error:

---------------------------------------------
Microsoft VBScript runtime error '800a0005'

Invalid procedure call or argument: 'DateDiff'

/date.asp, line 6

---------------------------------------------

Here is a sample of what I typed, maybe you can tell me what I'm doing wrong.

<%
Dim date1, date2, differs
date1 = &quot;6/17/1988&quot;
date2 = &quot;9/14/1997&quot;

differs = DateDiff(yyyy,date1,date2)

response.write differs
%>


Thx,
-Ovatvvon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top