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

Date compareing?

Status
Not open for further replies.

nebakanezer

Technical User
Feb 23, 2004
7
GB
Hi im trying to find twins who were born on the same day, iv tried

select X.surname, X.forenames, X.dob, Y.surname, Y.forenames
from student X, student Y
where X.surname = Y.surname
and X.dob = Y.dob;

and also

select surname,forenames,dob from student
where surname = surname
and dob = dob;

to no avail, any help appreciated.

 
And this ?
select X.surname, X.forenames, X.dob, Y.surname, Y.forenames
from student X, student Y
where X.surname = Y.surname
and X.forenames != Y.forenames
and X.dob = Y.dob;

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
just as a matter of curiosity, i'd be interested to know if your database has any twins that weren't born on the same day

rudy
SQL Consulting
 
Hi,
I had a friend in college that was born before midnight and his brother was born after midnight, thereby giving them different birthdays.


Here is a riddle I remember hearing a long time ago. Its amazing what you can find on the World wide web.



International Date Line Puzzle

--------------------------------------------------------------------------------

On a ship sailing from Hong Kong to San Francisco, a pair of twins is born. One twin is born early Friday morning, on January 1, 1965, at 1:00. Sixty minutes later, after crossing the International Date Line (and enterning a new time zone), the second twin is born on Thursday morning, at 3:00, December 31, 1964.

Which twin is older?

--------------------------------------------------------------------------------
Possible Answers:
A. The first twin is older, because she was born 60 minutes earlier.

B. The second twin is older, because the time on her birth certificate (3:00am December 31, 1964) precedes that of her sister's (1:00am January 1, 1965).




Then there is this twist on it.


At the time she went into labor, the mother of the twins was travelling by boat. The older twin, Terry, was born first early on March 1st. The boat then crossed the International Date line (or anytime zone line) and Kerry, the younger twin, was born on February the 28th. In a leap year the younger twin celebrates her birthday two days before her older brother.

 
select * from student where (surname,dob) in
(select surname,dob from student
group by surname,dob
having count(*) = 2)


Where "= 2" is for twins... If you also want triplets, change to ">= 2".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top