
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Anyone have a query or report for calculating the number of days between the purchase date (purchase_date) and the Installed date (install_date) in the alm_hardware table?
Looking for a report or procedure to create one so I can determine how many days between these two dates.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Same logic can be extended as below if you want to store duration as integer,
var gr = new GlideRecord('alm_hardware');
gr.addQuery('sys_id','=','00a96c0d3790200044e0bfc8bcbe5dc3');
gr.query();
while (gr.next()) {
var gdpt = new GlideDateTime(gr.purchase_date);
var gdit = new GlideDateTime(gr.install_date);
var duration = GlideDateTime.subtract(gdpt, gdit);
duration=duration.getNumericValue()/86400000;
gs.print(Math.floor(duration));
}
If this helped to answer your query please mark my posts helpful & accept the solution to close the thread.
Thanks,
Bhuvan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
That could also work. I think the field would have to be an integer field since we are wanting the number of 'Days' (e.g., 5, 40, 17).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Same logic can be extended as below if you want to store duration as integer,
var gr = new GlideRecord('alm_hardware');
gr.addQuery('sys_id','=','00a96c0d3790200044e0bfc8bcbe5dc3');
gr.query();
while (gr.next()) {
var gdpt = new GlideDateTime(gr.purchase_date);
var gdit = new GlideDateTime(gr.install_date);
var duration = GlideDateTime.subtract(gdpt, gdit);
duration=duration.getNumericValue()/86400000;
gs.print(Math.floor(duration));
}
If this helped to answer your query please mark my posts helpful & accept the solution to close the thread.
Thanks,
Bhuvan