Calculate difference in date field in years
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2016 02:03 AM
I have two fields which are date type (note date/time).
I want to get the difference in years. I am not able to find any function which gives result in years?
Can someone suggest?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2016 02:58 AM
My field is only Date type. It is not a DateTime field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2016 03:08 AM
Instead of GlideDateTime use GlideDate and use only yyyy-mm-dd format without time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2018 04:33 AM
Recently had to do similar thing.
var start = new GlideDateTime(current.start_date);
var end = new GlideDateTime(current.end_date);
var diff = GlideDateTime.subtract(end, start).getNumericValue();
var diff_year = diff/1000/60/60/24/365; // more or less year in milliseconds.