1

I'm trying to select all records where DateTimeEntered is within roughly 4 hours of variable MyDateTime. Any ideas how to do this? Here's what I was trying and it doesn't work for some obvious reasons. Apparently casting to double is not an option. Also, I'm only checking to see if the value of MyDateTime is less by less than .1 but I also need to check to see if it's greater but not greater than .1. I'm guessing there is a better way of doing this. Any ideas?

"SELECT ID from visit " & _
    "WHERE (Cast(datetimeentered AS Double) - " & CDbl(MyDateTime) & ") < .1"

1 Answer 1

3

The VBA in your Classic ASP may turn out to be something like

strVisits = strVisits & " Select * from Visit" & vbcrlf
strVisits = strVisits & " Where DateTimeEntered Between  DateAdd (hour, '" & MyDateTime& "', -2) "  & vbcrlf
strVisits = strVisits & " and DateAdd (hour, '" & MyDateTime& "', 2)"

That will basically do this (with the value of MyDateTime)

Select *
from Visit
Where DateTimeEntered Between  DateAdd (hour, MyDateTime, -2) and DateAdd (hour, MyDateTime, 2)
Sign up to request clarification or add additional context in comments.

1 Comment

Dude that was too simple. I already knew how to do it that way but I certainly hadn't thought of it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.