|
 |
access_asp thread: Date & Time
Message #1 by "Steve B. Johnson" <soysteve2000@y...> on Sun, 5 Jan 2003 18:43:22
|
|
I am calculating the difference between the current date & time and a date
& time stored in my database. The code,
sSQL = "SELECT ([Table]![DateField]-Now()) AS myVariable FROM myMdb "
works fine. The problem is that due to the zone where my site is hosted,
there is a five hour difference. I got around this using the code,
function myDateTime()
myDateTime = DateAdd("h", 5, _
CDate(Date() & " " & Time()))
end function
If I calculate Now()-myDateTime, the code is accepted, but when I
replace Now() with the myDateTime variable in the SQL statement , it
does not work.
PLEASE HELP, Steve.
Message #2 by "Ken Schaefer" <ken@a...> on Mon, 6 Jan 2003 11:34:25 +1100
|
|
You are calculating the date/time in your ASP code. You then need to format
it appropriately to place into your SQL statement (which is just a string):
www.adopenstatic.com/faq/dateswithaccess.asp
Also, next time you have a problem where "it does not work", please
elaborate on what does not work: do you get an error? Does it do nothing?
Does it do something, but not what you expect? etc
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Steve B. Johnson" <soysteve2000@y...>
Subject: [access_asp] Date & Time
: I am calculating the difference between the current date & time and a date
: & time stored in my database. The code,
: sSQL = "SELECT ([Table]![DateField]-Now()) AS myVariable FROM myMdb "
: works fine. The problem is that due to the zone where my site is hosted,
: there is a five hour difference. I got around this using the code,
:
: function myDateTime()
: myDateTime = DateAdd("h", 5, _
: CDate(Date() & " " & Time()))
: end function
:
: If I calculate Now()-myDateTime, the code is accepted, but when I
: replace Now() with the myDateTime variable in the SQL statement , it
: does not work.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
 |