Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Query

Status
Not open for further replies.

NEL3644

Technical User
Sep 4, 2000
26
US
I have 3 fields in one of the tables in my database that looks like:

Table name: Expiration

BeginDate EndDate E-mail
========= ======= =======
20001023 20001024 joe@yahoo.com
20001025 20001027 mike@yahoo.com
20001109 20001116 jmarcus@hotmail.com
.
.
.
........and so on...


Can anyone help me create a query where I can be able to always identify a date 1 week prior to last expired date (EndDate)?

This query will help me send an automatic e-mail that notifies a user that the pswd will expire in one week!

Thank you in advance!
 
Use the DATEADD function. To get all users where whos passwords will expire a week from today use:

SELECT * FROM TABLE1 WHERE DATEADD(wk, -1, EndDate) = GETDATE() Durkin
alandurkin@bigpond.com
 
And no, it doesn't actually get you a date for friday night! LOL

 
No you couldn't, actually, because user-definded functions in 2000 cannot be non-deterministic..


Tom
 
Mmmm...I hate to disagree with the master, but the indications from my research are that SQLS2K UDFs can be non-deterministic. However, it is true that you cannot use a non-deterministic function (such as the builtin GetDate function) in a user defined function.

In any event, my GetDate UDF would always return -1. My server insists that it be so.

Robert Bradley

 
Yes, if you call a udf and always get the same value back based on the same inputs, then it will work.. :)

Tom

 
But, I tried it with Beta 2, and even placing non-deterministic calls in it prevented compilation....

Tom
 
I'm sorry about my limited knowledge about SQL, but if I wanna learn more I have to ask you guys what non-deterministic user defined functions are.....
 
Tom, I don't have SQLS2K installed, so I'll have to rely on your reconnaissance.

NEL3644, a deterministic function is one that will always return the same value if passed the same argument(s). For example, ABS(-2) always returns the same value.

A non-deterministic function is one that, even with the same arguments, returns different values. The example we've been using is GETDATE(), which returns a different value every second.

Robert Bradley

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top