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!

Comparison of DATE

Status
Not open for further replies.

Justyn

Instructor
Oct 22, 2003
28
US
Hello all, I would like to ask fot the query if I want to compare two columns which are of DATE type, I need to get the latest date. Thanks a lot.
(Suppose two columns are "TMODDATE" and "TADDDATE").

:)

 
Hi,
Here is a sample query which will get the altest of two dates. The table used is employee table on sample database. Hope this helps.

DB2 "WITH TEMP AS (select case when (hiredate > birthdate) then 0 else 1 end as value from employee where empno = '000010') SELECT CASE VALUE WHEN 0 THEN HIREDATE ELSE BIRTHDATE END FROM TEMP,EMPLOYEE WHERE EMPNO='000010'"

Bye
GK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top