MySQL Forums
Forum List  »  General

Re: comparing dates
Posted by: Felix Geerinckx
Date: April 25, 2005 10:45AM

Anindya Mozumdar wrote:


> I have two variables named emp_hire_dt and emp_term_dt in a table. I want to remove all
> employees whose termination date is before hire date. Will the following work -
>
> delete from <tablename> where emp_term_dt < emp_hire_dt;


Yes, when the emp_hire_dt and emp_term_dt colums (or fields or attributes, but nor variables ;-)
are defined as DATE, DATETIME or TIMESTAMP.

When writing queries like the one you mention, it is always a good idea to "try" first with

SELECT * from <tablename> WHERE emp_term_ft < emp_hire_dt;

so you can see what you get.

--
felix

Options: ReplyQuote


Subject
Written By
Posted
April 25, 2005 09:38AM
Re: comparing dates
April 25, 2005 10:45AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.