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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparision of Date fields

Status
Not open for further replies.

RptSm

MIS
Dec 28, 2004
19
US
I need a derived field or formula that looks at status =A and Rehire date > Term Date = Rehire else Hire date. I am using PCPW 5.2 Oracle database. Any help is greatly appreciated.
 
What do You want to return if Status is not A?

CharlesCook.com
ADP - PeopleSoft - SAP
ReportSmith - Crystal Reports - SQR - Query - Access
Reporting - Interfaces - Data Mining
 
A null value, I guess. My issue is that I have active employees with a term date & a rehire date but the rehire date should be greater than the term date. I hope this made sense?
 
This should work:

DECODE(Status,'A',
CASE WHEN rehiredate > termdate then rehiredate
ELSE termdate
END,
NULL)

THE UNDERLINED AND BOLDED BITS NEED TO BE THE ACTUAL DATA FIELD NAMES.

CharlesCook.com
ADP - PeopleSoft - SAP
ReportSmith - Crystal Reports - SQR - Query - Access
Reporting - Interfaces - Data Mining
 
Thanks this works. Except I am still getting 2 rows. Should Term date & Rehire date be in query only,so that I just get the most recent (active) record?

Using this case function is new to me can it be used to handle multiple criteria like a nested if statement? Any examples would be great.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top