MySQL Forums
Forum List  »  Newbie

DATEDIFF problem
Posted by: Hans Kanns
Date: February 29, 2016 02:00AM

Hello,
i am trying to figure out how soon employees will have birthday.
But

SELECT DATEDIFF( CONCAT( YEAR( CURRENT_DATE ) , "-", MONTH( birthday ) , "-", DAY( birthday) ) , CURRENT_DATE ) FROM employee;


gives out a different result on some tuples compared to

SELECT DAYOFYEAR( birthday ) - DAYOFYEAR( CURRENT_DATE ) FROM employee;

Some results differ by one day.
kindly help me figure out why and which SELECT-statement is the better one. Thanks!

Options: ReplyQuote


Subject
Written By
Posted
DATEDIFF problem
February 29, 2016 02:00AM
February 29, 2016 10:08AM
February 29, 2016 06:43PM
March 07, 2016 10:31PM


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.