473,407 Members | 2,359 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,407 software developers and data experts.

Records newer than 90 minutes (smalldatetime)

Hi,

I have a table in SQLServer2000 where e.g. the actual time is insert for
every record (smalldatetime). But how do I select every records newer
than 90 minutes?

/Chris
Jul 20 '05 #1
4 1848
On Mon, 08 Nov 2004 21:24:33 +0100, Chris wrote:
Hi,

I have a table in SQLServer2000 where e.g. the actual time is insert for
every record (smalldatetime). But how do I select every records newer
than 90 minutes?

/Chris


Hi Chris,

SELECT Column1, Column2, ..., ColumnN
FROM MyTable
WHERE InsertionTime > DATEADD(minute, -90, CURRENT_TIMESTAMP)

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Jul 20 '05 #2
On Mon, 08 Nov 2004 21:24:33 +0100, Chris wrote:
Hi,

I have a table in SQLServer2000 where e.g. the actual time is insert for
every record (smalldatetime). But how do I select every records newer
than 90 minutes?

/Chris


SELECT * FROM Tbl WHERE DateDiff(m,time_column,GetDate()) BETWEEN 0 AND 90

And you'd better have an index on your time_column.
Jul 20 '05 #3
On Mon, 8 Nov 2004 16:45:45 -0500, Ross Presser wrote:
On Mon, 08 Nov 2004 21:24:33 +0100, Chris wrote:
Hi,

I have a table in SQLServer2000 where e.g. the actual time is insert for
every record (smalldatetime). But how do I select every records newer
than 90 minutes?

/Chris


SELECT * FROM Tbl WHERE DateDiff(m,time_column,GetDate()) BETWEEN 0 AND 90

And you'd better have an index on your time_column.


Hi Ross,

As far as I know, that index won't be used in your query, since the
time_column is embedded in a function call. You'd have to have the
time_column all by itself at one side of a comparison operator (like in my
query) for the index to be useful.

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Jul 20 '05 #4
Hugo Kornelis <hugo@pe_NO_rFact.in_SPAM_fo> wrote in
news:kp********************************@4ax.com:
On Mon, 8 Nov 2004 16:45:45 -0500, Ross Presser wrote:
On Mon, 08 Nov 2004 21:24:33 +0100, Chris wrote:
Hi,

I have a table in SQLServer2000 where e.g. the actual time is insert
for every record (smalldatetime). But how do I select every records
newer than 90 minutes?

/Chris


SELECT * FROM Tbl WHERE DateDiff(m,time_column,GetDate()) BETWEEN 0
AND 90

And you'd better have an index on your time_column.


Hi Ross,

As far as I know, that index won't be used in your query, since the
time_column is embedded in a function call. You'd have to have the
time_column all by itself at one side of a comparison operator (like
in my query) for the index to be useful.

Best, Hugo


Thank you for clarifying my fuzzy thinking, Hugo. Your query is much better
in that respect.
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Edward | last post by:
SQL Server 7.0 If I run the following in Query Analyzer I get no records returned: exec GetLeadsOutcome_Dealer '1/1/2003','12/2/2003',10, '176, 183' If, however, I run either : exec...
3
by: siatki | last post by:
Hello, Firstly, sorry for my english. I have problem with creating SQL statement. I am beginner and I think that it is very easy to do. Look - I have to get only the last 20 records from table...
6
by: CJM | last post by:
I've created a Stored Procedure which adds a new record and updates some more records and then returns the primary key for the added record. The SP seems to work OK, but I'm having problems...
2
by: Salim Afţar | last post by:
Hi, How can I cast from datetime type to smalldatetime type. I get the records from a table which has got a datetime type column but I want to display it smalldatetime format. Thanks, Salim
1
by: Fred Nelson | last post by:
Hi: I'm a relative Newby writing my first vb.net web application that uses SQL SmallDateTime fields. I have some records that contain null values in the datetime fields and they return...
6
by: SQL Server | last post by:
I've been working this for a while. Kind of new to SQL Server functions and not seeing what I am doing wrong. I have this function CREATE FUNCTION dbo.test (@Group varchar(50)) RETURNS...
0
by: kolalakitty | last post by:
Hopefully someone here can help me/point me in the right direction. I've found tons of references towards making relations, creating rows, saving said rows, using datagrids, databinding objects,...
1
by: Lin100 | last post by:
Access ADP and Stored Procedure Did not Return Any Records Access 2002 and SQL 2000 Server I have a form named "Selector", and it have four combo boxes and a subform named...
3
by: shaif | last post by:
Hi all, I am working on a module of Php project with SQL server. I design a date filed in the table smalldatetime types. I want to get Hour and minutes. I write the code bellow: Its works for hour...
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
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...
0
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,...
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
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...
0
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...
0
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,...
0
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...

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.