473,804 Members | 3,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL2000- How to use DateDiff Function together with (If then..else)

7 New Member
Hi, I am new to this forum please help.

I need to schedule a job to send out an email if found there is a records older than 1 minute (compare to current date time against createddate) and the email will contain the itemid.

mytable design
1.) itemid int
createddate getdatetime()
summaryid varchar
startdate datetime
enddate datetime

this is what i have done

SELECT TOP 1*,DATEDIFF(mI, createdate, getdate()) AS ms
FROM mytable

Can anyone advised on this...
i was also thinking putting in the


set rowcount 1
if (SELECT DATEDIFF(mI, createdate, getdate())FROM prontoqueue) > 5
begin
Print 'more than 5'
end
else
Print 'less than 5'
setrowcount 0



i am hitting an error message...
Server: Msg 512, Level 16, State 1, Line 2
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
less than 5


please advised....than k you
Sep 11 '08 #1
2 2632
Delerna
1,134 Recognized Expert Top Contributor
Try this
Expand|Select|Wrap|Line Numbers
  1. if (SELECT count(DATEDIFF(mI, createdate, getdate())) FROM prontoqueue) > 5
  2. begin
  3. Print 'more than 5'
  4. end 
  5. else 
  6. Print 'less than 5'
  7.  
  8.  
Sep 11 '08 #2
lbseong
7 New Member
this is cool...is working. thanks
Sep 12 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2847
by: info | last post by:
Can some one show me how to use the datediff function where the dates are being supplied through an access db. For instance, a recordset would contain these fields: DateAssigned, DateDue, ProjectName, ProjectDetail, Class. The student enters a project name, then a date it was assigned and a date it is due...and other details about the project into the appropriate fields. The projects appear in a databound list box...when you click on a...
5
6693
by: mcbill20 | last post by:
Hello all. I have a really basic question that I hope someone has a better answer for. I apologize in advance-- I know this is probably a really basic question but I am used to Oracle rathern than Access. I have a database where they customer wants to purge records from certain tables after three years. When I was asked to make the changes I originally thought this was an incredibly simple thing to do. I looked at the function list and...
2
4266
by: Derrick | last post by:
I've included using Microsoft.VisualBasic, cranked up a VBCodeProvider, the only class I see in there, don't see DateDiff as a method though? Thanks in advance!! Derrick
7
6498
by: reney | last post by:
I am trying to return the difference in minutes from a starttime and stoptime using the datediff function in a Web Project with VB.Net With: StartTime = 2/10/2006 8:46:03 PM EndTime = 2/10/2006 8:48:10 PM I am getting a return value of 1054586688 in the diff variable I tryed this same code in a Windows.Net Project and I get a return of 2 as I
1
1973
by: KMEscherich | last post by:
Using Access '97 Hi there. I have a field that uses a DateDiff function to count the number of days between a DATE field and DATE(), is there a way to have the counter stop counting days when the FINISHED checkbox has been selected?? =DateDiff("d",,Date()) & " DAYS HAVE PASSED SINCE THE SRI SUBMITTED DATE" Thank you in advance for your assistance. K_Escherich
4
112889
by: misaw | last post by:
for portability in SQL query ie a query written for one DB runs fine for other i try to standardize our SQL queries as far as i can.... For finding the date difference we have: DATEDIFF function in SQL Server - operator in Oracle ... i want to Sync this also how would i do that i tried to create same name function in Oracle but having problem... of parameter type....what interval type should i take so that it works like SQL server...
14
3581
by: cmdolcet69 | last post by:
I'm trying to use the DateDiff function to calculate the difference whether a shift has been setup. when i run the code below with strFirstShiftEnd as a stringor date or datetime. I get an error Argument Date1 cannot be converted to type Date. an anyone clear this up. If DateDiff("n", Format(Now, "hh:mm AMPM"), Format(strFirstShiftEnd, "hh:mm AMPM")) <= 0 Then 'logout MsgBox("A shift change has occurred. You will be logged
1
2275
by: cptcanada | last post by:
Hi All, I am getting an error saying that now() is not a reconized function in my datediff function would any one know why it is not being reconized? Thanks for the help ------------------------------------------------------------------------------------------------------------- USE Master EXEC xp_startmail 'outlook', 'drive8'
2
1930
by: bandy | last post by:
Hi, I am using datediff() function to get difference between two dates. my code looks like, function dateDiff($dformat, $endDate, $beginDate) { $date_parts1 = explode($dformat, $beginDate); $date_parts2 = explode($dformat, $endDate); $start_date = gregoriantojd($date_parts1, $date_parts1, $date_parts1); $end_date = gregoriantojd($date_parts2, $date_parts2, $date_parts2);
0
9706
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
10571
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10326
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7615
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...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4295
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
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
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.