Im trying to retrieve the month difference of two dates but it seems like i cant find a way to get the accurate months.
Here are the queries i tried so far :
SELECT DATEDIFF(month,convert(datetime, '11/05/2015'), convert(datetime, '12/06/2015')) - 1
This will result to 0 which is wrong and when i used another date :
SELECT DATEDIFF(month,convert(datetime, '12/31/2015'), convert(datetime, '01/01/2016')) - 1
This would yield to 1.
Leap year must also be considered.
Aucun commentaire:
Enregistrer un commentaire