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 2000 Forums
 SQL Server Development (2000)
 Date comparison

Author  Topic 

qchau_98
Starting Member

6 Posts

Posted - 2002-06-06 : 15:22:40
I am using a store procedure with the cursor to select employee start date (fomrat 01/01/2002) from the employee table. With the cursor how would I do a comparsion between today date and the start day. So if an employee work over 6 months the system will send an email to the employee which he/she eligable for the 401k enrollment.
So, I would like to know what function to use for comparsion of the date.

Thanks in advance,
Quan

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-06-06 : 15:38:41
#1, you don't need a cursor to determine date ranges. #2, you don't need a cursor AT ALL for this process.

Look at the DateDiff and DateAdd functions in Books Online. If you need more help, you'll have to post your code.

Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2002-06-06 : 15:40:49
couple of things....


1....try to stay away from cursors....there's plenty of advice here to support this statement....most things can be done without them, far more efficiently....search for cursors...and be ready for a lot of returned topics!!!!


2....search for datediff or dateadd....the solution you want involve 1 or the other of those keywords...and i saw a solution posted in a recent link.....but can't find it now.

3....your dateformat...01/01/2002...doesn't tell me whether or not it is dd/mm/yyyy or mm/dd/yyyy.....it'll matter when you put 12/13/2002 into dd/mm/yyyy...!!!!


regards
andrew

Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2002-06-06 : 15:41:46
heads down....sniper about!!!

Go to Top of Page
   

- Advertisement -