473,387 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 1905
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Devonish | last post by:
I am planning to convert an existing Access database which has a back end (data tables and relationships only) on a server and a copy of the front end (form, queries, reports) on each of about a...
1
by: Jim Devenish | last post by:
I am continuing my exploration about upsizing to SQLServer from Access 2000. I have a split database with a front-end and a back-end, each of which is A2K. I have spent some time in bookshops...
2
by: codejockey | last post by:
I have a simple project that requires I take a set of data from an Excel spreadsheet, compare it to a table in SQL Server (where column names match), and if there are changes in the Excel sheet,...
0
by: codejockey | last post by:
Please forgive the repost, but I'm trying to avoid the hack I want to implement since I cant get this sample to work. Can anyone help? *********************** William: Thanks for the reply. I...
1
by: Sunit Joshi | last post by:
Hello I have a situation like this, I have 2 colns in an SQLServer table which are set to following SQLServer data types sTime->Binary (length=8), and tTime -> Int (length=4) I need to compare...
14
by: Roy Gourgi | last post by:
Hi, I need to store and retrieve information from a database. It looks as though there is a lot more support for SQLServer than there is for Access, correct me if I am wrong. What do I have...
4
by: SQLNewbie | last post by:
I have the following cursor that I am comparing 2 tables, the production table and a copy of the production table, I want results of all address's that are like the address1 field...the problem...
4
by: Rick | last post by:
I've moved code from a stage machine to the production machine, exact same code works fine on the stage machine, they are both windows 2003 servers, I'm getting a "Cannot generate SSPI context"...
7
by: sachinkale123 | last post by:
I want to stop Sql server Agent Windows service. I am using below code to stop or start the windows service. Which is I am doing sucessfully. ManagedComputer mc = default(ManagedComputer); ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.