473,831 Members | 2,398 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1928
ol**@ylm.se wrote in news:1189260870 .904389.29020
@w3g2000hsg.goo glegroups.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
1869
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 dozen workstations. I intend to convert the back end to SqlServer and wish to use the upsizing wizard. I am acquiring SSW Upsizing Pro! 2000 which seems to be recommended in other discussions.
1
1721
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 trying to learn about the way forward and trying to decide which to buy. The bit I am interested in is usually at page 900 and I am not sure whether I want to buy the first 800. It appears that upsizing creates an Access project as the...
2
9965
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, update the SQL Server table with said changes. The datasets are about 2000 rows. My thinking is performing a check row by row is inefficient, so I thought about how I could compare the two as datasets and resolve differences. The SQL Server table...
0
1585
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 havent been able to get the sample to work. I notice the cursor cycling through the Excel records, but the SQL table always shows up empty. Notice anything wrong here?
1
1923
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 the 2 values and was looking for the best way to do this. Any hints are greatly appreciated. thanks
14
2144
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 to do to get SQLServer and which version should I be using. Or is SQLServer already part of the VS.Net? Are there any good examples that you know of.
4
2668
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 is...my results are giving me every field and if there is more than one, it is putting it in a grid.... I only want to see results if they are 1 for the same address field this is what I have so far....
4
4158
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" error, there are other sites on this server that access the same database. IIS is the same, permissions to the database are correct. Any suggestions? Error:
7
8318
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); mc = new ManagedComputer(); Service svc = default(Service); svc = mc.Services; if (svc.ServiceState == ServiceState.Running) {
0
9793
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9642
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10534
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10208
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9317
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7748
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4417
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3964
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3076
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.