472,142 Members | 1,033 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,142 software developers and data experts.

how tgo compare datevalues in sqlserver, asp and Access

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

Sep 8 '07 #1
1 1844
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

Sep 8 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Devonish | last post: by
2 posts views Thread by codejockey | last post: by
reply views Thread by codejockey | last post: by
1 post views Thread by Sunit Joshi | last post: by
14 posts views Thread by Roy Gourgi | last post: by
4 posts views Thread by Rick | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.