ol**@ylm.se wrote in news:1189260870.904389.29020
@w3g2000hsg.googlegroups.com:
hi I have a real problems with comparering date in asp and
sqlserver
In sqlserver I have a table tblDates with the field dtmDate
the field dtmDate in a sqlserver table may contain a date like
2005-07-30 08:46:54.000
(it was eported from Access)
and then in asp I want to create a date like:
DIM MYDATE
MYDATE = now()
( which is for example 9/8/2007 3:51:51 PM )
THEN i WANT TO substract 6 months from MyDate
( if mydate is 9/8/2007 3:51:51 PM I want it to become
9/2/2007 3:51:51 )
and then I would like to use a sqlstring like
select * from tbldate Where & " dtmdate >= "& mydate
but as the dates formatted differently in sqlserver and asp I
don't
know how to handle this.
Hope that someone may help me with this.
Regards BigOlle
Format of dates is irrelevant. Access, SQL Server and whatever
engine you use behind the asp all store the date as a real number
with the fractional part of the number as time in percent of a day,
and the integer part representing the offset from day 0.
The number is converted in code to represent a date.
For comparison purposes, you just have to set the format of each
source to be the same as the other. using the # delimiter advises VB
and SQL that the number is to be treated as a date number. It's not
required around dtmdate because SQL knows the field dtmdate is a
date.
So
Dim mydate as date
Mydate = dateadd("m",-6,now())
SQL = "SELECT * FROM tbldate WHERE dtmDate >= #" & mydate & "#;"
--
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from
http://www.teranews.com