select *,
datediff(Y,employee.joiningdate,getdate()) "retirementdate"
from employee
How to get the mm-dd-yyyy format ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The datediff function doesn’t return a date, so you can’t format it as a date. If it’s date formatting you want then you should take a look at this msdn article: http://msdn.microsoft.com/en-us/library/ms187928.aspx
If you just want to know how to format a date in sql :
But you should not convert dates in sql. Keep dates as dates and do the formatting in your application.