Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Time alert

Author  Topic 

dhjackal
Starting Member

42 Posts

Posted - 2011-12-09 : 05:59:31
Hello all,

Hoping someone can help me with the following issue. I need to send an alert if real time is within 30 minutes of a meeting stating i.e

Meeting time 15:00
Acutal time 14:00

If the actual time is beween 14:30 and 15:00 send alert

Thanks in advance

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-09 : 06:01:34
is this t-sql requirement?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

dhjackal
Starting Member

42 Posts

Posted - 2011-12-09 : 06:15:46
Yes

the logic is as follows

@meetingTime = 15:00
@actualTime = 14:45

IF actualTime within 30 minutes of meeting time
BEGIN
return row of data
END
ELSE
print message
Go to Top of Page

dhjackal
Starting Member

42 Posts

Posted - 2011-12-09 : 07:03:58
I need something like this ;

AND startdatetime BETWEEN DateADD(mi, -30, Current_TimeStamp) AND current_timestamp

but it doesn't seem to work
Go to Top of Page

dhjackal
Starting Member

42 Posts

Posted - 2011-12-09 : 07:27:55
This did the trick ;

AND startdatetime > DateADD(mi, -30, Current_TimeStamp)

hope it helps someone else
Go to Top of Page

dhjackal
Starting Member

42 Posts

Posted - 2011-12-09 : 07:37:51
This works even better ;

AND (startdatetime <= current_timestamp OR startdatetime > DateADD(mi, -30, Current_TimeStamp))

i.e the meeting is either current and running or within 30 minutes of starting
Go to Top of Page

dhjackal
Starting Member

42 Posts

Posted - 2011-12-09 : 08:03:07
I finally settled on ;

AND (startdatetime <= current_timestamp OR startdatetime BETWEEN startdatetime AND DateADD(mi, -30, Current_TimeStamp))'
Go to Top of Page

dhjackal
Starting Member

42 Posts

Posted - 2011-12-09 : 08:19:39
However, that didn't work as expected so i fixed it with ;

AND (startdatetime <= current_timestamp OR startdatetime BETWEEN Current_TimeStamp AND DateADD(mi, +30, Current_TimeStamp))'
Go to Top of Page

dhjackal
Starting Member

42 Posts

Posted - 2011-12-09 : 08:19:59
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-09 : 08:35:16
is the last one equivalent of below?

AND startdatetime <= DateADD(mi, +30, Current_TimeStamp)


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -