Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 02:19 PM
Steven Scaife
Guest
 
Posts: n/a
Default working out time passed between two dates

I am trying to work out the length of time that a page was opened till it
reached another page, I amusing the script below

End_Of_Call = formatdatetime(now(), 0)

'work out the duration of the call
duration = End_Of_Call - cdate(vTime)
response.write isdate(End_Of_Call)
response.write isdate(vTime)
'response.write duration
response.End()

but it errors and i get

Microsoft VBScript runtime (0x800A000D)
Type mismatch: '[string: "7/21/2004 2:34:49 PM"]'
/testing/process_new.asp, line 30

I cant understand why it doesn't work, it is being run on the same server as
before and is identical code, except i dont use formatdatetime on both
variables to set them, if i remove formatdatetime i still get type mismatch,
any ideas how i can make this work. thanks


  #2  
Old July 19th, 2005, 02:19 PM
Steven Scaife
Guest
 
Posts: n/a
Default Re: working out time passed between two dates

all i get when i dont get that error is something like so
3.00925930787344E-04

when i use duration = now() + 10 - now() - get 10

cant understand why it doesn't do it, really annoying as this way used to
work

"Steven Scaife" <nospam> wrote in message
news:#MEnqhybEHA.216@TK2MSFTNGP10.phx.gbl...[color=blue]
> I am trying to work out the length of time that a page was opened till it
> reached another page, I amusing the script below
>
> End_Of_Call = formatdatetime(now(), 0)
>
> 'work out the duration of the call
> duration = End_Of_Call - cdate(vTime)
> response.write isdate(End_Of_Call)
> response.write isdate(vTime)
> 'response.write duration
> response.End()
>
> but it errors and i get
>
> Microsoft VBScript runtime (0x800A000D)
> Type mismatch: '[string: "7/21/2004 2:34:49 PM"]'
> /testing/process_new.asp, line 30
>
> I cant understand why it doesn't work, it is being run on the same server[/color]
as[color=blue]
> before and is identical code, except i dont use formatdatetime on both
> variables to set them, if i remove formatdatetime i still get type[/color]
mismatch,[color=blue]
> any ideas how i can make this work. thanks
>
>[/color]


  #3  
Old July 19th, 2005, 02:19 PM
Ray at
Guest
 
Posts: n/a
Default Re: working out time passed between two dates

Use the DateDiff function:

<quote>
Returns the number of intervals between two dates.

DateDiff(interval, date1, date2 [,firstdayofweek[, firstweekofyear]])
</quote>




'work out the duration of the call

duration = DateDiff("s", Now, vTime)
response.write duration
response.End

That will tell you how many seconds have passed. For more info on the
DateDiff function, see your WSH documentation that you downloaded and
installed from
http://www.microsoft.com/downloads/d...6-1C4099D7BBB9

Ray at work


"Steven Scaife" <nospam> wrote in message
news:%23MEnqhybEHA.216@TK2MSFTNGP10.phx.gbl...[color=blue]
>I am trying to work out the length of time that a page was opened till it
> reached another page, I amusing the script below
>
> End_Of_Call = formatdatetime(now(), 0)
>
> 'work out the duration of the call
> duration = End_Of_Call - cdate(vTime)
> response.write isdate(End_Of_Call)
> response.write isdate(vTime)
> 'response.write duration
> response.End()
>
> but it errors and i get
>
> Microsoft VBScript runtime (0x800A000D)
> Type mismatch: '[string: "7/21/2004 2:34:49 PM"]'
> /testing/process_new.asp, line 30
>
> I cant understand why it doesn't work, it is being run on the same server
> as
> before and is identical code, except i dont use formatdatetime on both
> variables to set them, if i remove formatdatetime i still get type
> mismatch,
> any ideas how i can make this work. thanks
>
>[/color]


  #4  
Old July 19th, 2005, 02:19 PM
Aaron [SQL Server MVP]
Guest
 
Posts: n/a
Default Re: working out time passed between two dates

Why are you using subtraction? Do you even know what the default unit is
for date/time-based math? Why don't you use datediff instead of confusing
things with this shorthand?

--
http://www.aspfaq.com/
(Reverse address to reply.)




"Steven Scaife" <nospam> wrote in message
news:#MEnqhybEHA.216@TK2MSFTNGP10.phx.gbl...[color=blue]
> I am trying to work out the length of time that a page was opened till it
> reached another page, I amusing the script below
>
> End_Of_Call = formatdatetime(now(), 0)
>
> 'work out the duration of the call
> duration = End_Of_Call - cdate(vTime)
> response.write isdate(End_Of_Call)
> response.write isdate(vTime)
> 'response.write duration
> response.End()
>
> but it errors and i get
>
> Microsoft VBScript runtime (0x800A000D)
> Type mismatch: '[string: "7/21/2004 2:34:49 PM"]'
> /testing/process_new.asp, line 30
>
> I cant understand why it doesn't work, it is being run on the same server[/color]
as[color=blue]
> before and is identical code, except i dont use formatdatetime on both
> variables to set them, if i remove formatdatetime i still get type[/color]
mismatch,[color=blue]
> any ideas how i can make this work. thanks
>
>[/color]


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles