473,385 Members | 1,409 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,385 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 1904
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.