473,385 Members | 1,830 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.

Compare datetimes

Hi

I need to retrieve data from a table comparing datetimes. I mean I've a
table with a datetime data and I'll need to retrieve rows with date time
now and date time < now + 5 minutes...


Is this posible ? Which is the best / easy way ?

Thanks in advance

J

Jul 23 '05 #1
2 2121

"Javier" <jl****@manresa.net> wrote in message
news:cu**********@news.ya.com...
Hi

I need to retrieve data from a table comparing datetimes. I mean I've a
table with a datetime data and I'll need to retrieve rows with date time
now and date time < now + 5 minutes...


Is this posible ? Which is the best / easy way ?

Thanks in advance

J


Check out DATEADD() in Books Online.

select col1, col2, ...
from dbo.MyTable
where dtcol > getdate()
and dtcol < dateadd(mi, 5, getdate())

Simon
Jul 23 '05 #2
On Mon, 07 Feb 2005 20:34:05 +0100, Javier wrote:
Hi

I need to retrieve data from a table comparing datetimes. I mean I've a
table with a datetime data and I'll need to retrieve rows with date time
now and date time < now + 5 minutes...


Is this posible ? Which is the best / easy way ?


Hi Javier,

SELECT Column1, Column2, ...
FROM MyTable
WHERE MyDatetimeColumn > CURRENT_TIMESTAMP
AND MyDatetimeColumn < DATEADD(minute, 5, CURRENT_TIMESTAMP)

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Jul 23 '05 #3

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

Similar topics

5
by: akoper | last post by:
I have a table that is a project. Each record is a task in the project. One field in each record is a date/time stamp for when that task was completed. I need to be able to: 1) compute how much...
4
by: Michael Pfeifer | last post by:
Hi all, I need to convert datetimes from any timezone to UTC and back considering daylight saving. It is not enough, to just add or subtract the timezone offset. Also, I can not use c functions...
6
by: Tom | last post by:
Hi, I would like to know how to compare date in C#? e.g. System.DateTime.Now > 2005-10-17 19:55:04 Thanks
9
by: tshad | last post by:
I am trying to set a date in a DateTime variable that I get from a user: DateTime theDate; theDate = "08-15-05"; This gives me an error: Cannot implicitly convert type 'string' to...
1
by: Manny Chohan | last post by:
i have two date fields for event start date and end date. I let the user enter two on create event page. on submit, i need to compare if the end date is earlier than start date or not. How can i...
12
by: conckrish | last post by:
Hi all.. Can anyone tell me how to compare datetime objects?I ve three objects namely Current date,start date and end date.. I need to check the current date with Start date and end date....Plz...
3
by: Pieter Coucke | last post by:
Hi, For some reason, somewhere in my application 1 hour is added to my dates, depending in which time zone the application is run... Because I don't have a clue where this happens, I posted this...
1
by: Will | last post by:
This little puzzle has been bugging me for some time. I'm trying to create a little service that will check a time frame and compare it to another timeframe (start / stop time). A real-world...
1
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post by:
I'm writing a demo website in VB/Dot Net 2.0. The database is SQL 2000 and the design is at least partially legacy. (And this is the first real web work I've done in 2.0. All previous work was...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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?

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.