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
 Transact-SQL (2000)
 question on working with dates in sql (help)

Author  Topic 

csphard
Posting Yak Master

113 Posts

Posted - 2002-09-23 : 18:51:44
I want to check for delinquent items

I need to do the following.

if the eval_type field is probation then calculate the delinquent date as:
create an alias by taking the date in todate field and change it to the same day last month.

if the eval_type field is annual then calculate the delinquent date as
create an alias by taking the date in todate field and change it to to the first of next month.


I'm current doing this using asp. I just loop through the records creating the delinquent date using dateSerial example below. I know there has go to be a better way. My way brings me all the records. I want to only get those records that are delinquent.
if annual then
strDeliquentDate = DateSerial(Year(strDate),Month(strDate)+2,1)
elseif strEval = "Probation" then
strDeliquentDate = DateSerial(Year(strDate),Month(strDate)-1,15)


How could i perform this using sql.


MichaelP
Jedi Yak

2489 Posts

Posted - 2002-09-23 : 19:08:36
This would be easier if I had the CREATE TABLE statements, but here goes:

 
SELECT field1, field2,
CASE eval_type
WHEN 'probation' THEN <insert date logic here>
WHEN 'annual' THEN <insert date logic here>
END AS DeliquentDate


Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page
   

- Advertisement -