Help!! I can't figure out the correct syntax

T

Tim

In an ASP web page I am trying to calculate a value in seconds from
two date and times. Can anyone help me find the correct syntax to make
this work?!?!

(This code below work correctly)
DetectionTime=#7/30/03 10:36:45 AM#
MyTime=#7/30/03 10:36:45 PM#
TTClose=(MyTime)-(DetectionTime)
TTTClose=(((TTClose*24)*60)*60)


(This code does not work)
DetectionTime=" # " & RS("DetectionTime") & "# "
MyTime = "#" & FormatDateTime(Now,2) & " " & Time & "#"
TTClose=(MyTime)-(DetectionTime)
TTTClose=(((TTClose*24)*60)*60)

(Error message)
Microsoft VBScript runtime error '800a000d'

Type mismatch: '[string: "#7/31/03 9:41:21 AM#"]'

/mcDevtest/Calculate.asp, line 18
 
R

Ray at

You're trying to subtract strings.

There are a few things.

1. You should not need to put the #'s around your RS("DetectionTime")
2. Why are you formatting Now() to strip the time and then concatenating
the time right back to it? You can just use Now() by itself, or use 0 for
the formatdatetime argument if you prefer.
3. Take a look at DateDiff in your WSH documentation, or online at
http://msdn.microsoft.com/library/en-us/script56/html/vsfctdatediff.asp

Ray at work
 
T

Tim

Thanks for your help! That is what I needed.


Ray at said:
You're trying to subtract strings.

There are a few things.

1. You should not need to put the #'s around your RS("DetectionTime")
2. Why are you formatting Now() to strip the time and then concatenating
the time right back to it? You can just use Now() by itself, or use 0 for
the formatdatetime argument if you prefer.
3. Take a look at DateDiff in your WSH documentation, or online at
http://msdn.microsoft.com/library/en-us/script56/html/vsfctdatediff.asp

Ray at work

Tim said:
In an ASP web page I am trying to calculate a value in seconds from
two date and times. Can anyone help me find the correct syntax to make
this work?!?!

(This code below work correctly)
DetectionTime=#7/30/03 10:36:45 AM#
MyTime=#7/30/03 10:36:45 PM#
TTClose=(MyTime)-(DetectionTime)
TTTClose=(((TTClose*24)*60)*60)


(This code does not work)
DetectionTime=" # " & RS("DetectionTime") & "# "
MyTime = "#" & FormatDateTime(Now,2) & " " & Time & "#"
TTClose=(MyTime)-(DetectionTime)
TTTClose=(((TTClose*24)*60)*60)

(Error message)
Microsoft VBScript runtime error '800a000d'

Type mismatch: '[string: "#7/31/03 9:41:21 AM#"]'

/mcDevtest/Calculate.asp, line 18
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top