Basit Khan

Basit Khan

  • NA
  • 336
  • 122.6k

How to get the Year in between two dates

Apr 6 2016 3:33 AM
Dear,
I have leave table
The Fields are
EmpNo
EmpName
LeaveStart
LeaveEnd
I want to show the leave taken by year.
i use datediff(dd,LeaveStart,LeaveEnd) it will shows the no. of days have taken.
but i want to show yearly wise.
E.g
2014 - 10 days
2015 - 16 days
how & where i can use year function becoz have leavestart & leaveend
suppose if employee taken a leave
LeavStart- 28-Dec-2015
LeaveEnd - 05-Jan-2016
then result should
2015 - 4 days
2016 - 5 days
then how to use query.
please help on this
Thanks
Basit.

Answers (2)