sql query of datediff between two columns

10 pts.
Tags:
SQL 2000
i am having one table in sql 2000 that is called (personal), in that table i am having two columns name date of birth(dob) and date of enrollment(doe). i want to write a query to get the actual difference between two date i.e like 10 years 03 months 22 days. Can somebody help me out of this. An early reply will be highly appreciated. thanks to all!!!!!!!!

Software/Hardware used:
software
ASKED: October 12, 2012  5:01 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    It can be done, but it could be tricky.  This is the idea (which you would need to translate into code): -Use DateDiff to calculate the difference in years. -Check the start and end dates to see if the years returned are correct or need to be adjusted (because of the way the DateDiff function works). -Use DateAdd to add the above number of years to the initial date, and start the process again with that initial date to calculate the months difference, and then the same for days.  It should be possible to do it in a single command with CASE expressions and combinations of DateDiff and DateAdd calls.  An easier way to do it could exist, but I am not aware of it (I am by no means an SQL Server expert).
    65,110 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following