- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2016 06:30 AM
I want to to use a group of records from pa_scores in a Map Page script,
and I want to return values where the start_to date is last month, however
start_to is an integer date value, so how do I convert a standard glide date
into an integer date like so:
var date = new GlideDate();
date.setValue(gs.beginningOfLastMonth());
// convert here ?
gs.print(date /*as an integer date i.e 29012016*/ );
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2016 06:51 AM
You should be able to do like this:
var date = new GlideDate();
date.setValue(gs.beginningOfLastMonth());
var dateasint = date.toString().replace('-','');
gs.print(dateasint);
and if it need to "really" be a integer you can do like this:
var date = new GlideDate();
date.setValue(gs.beginningOfLastMonth());
var dateasint = parseInt(date.toString().replace('-',''));
gs.print(dateasint);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2016 06:38 AM
Working with date objects makes my inner child cry.
This is the wiki page I always go to when I have to work with them: GlideSystem Date and Time Functions - ServiceNow Wiki
Lacking finesse in this area I'd probably do something awful like extract the day, month, and year as strings, concatenate them, and then make the resulting string an integer.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2016 06:47 AM
Hey!
This is what you are looking for: gs.print(date.getNumericValue());
For other good glide date stuff look in these places:
GlideDateTime - ServiceNow Wiki
GlideSystem Date and Time Functions - ServiceNow Wiki
Scoped GlideDate API Reference - ServiceNow Wiki
Using Date and Time Fields - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2016 06:53 AM
Well numericvalue gives the numbers of seconds from 1970(?).
As I understand it he wants the date to be without the - so instead of 2016-01-29 he wants 20160129 (well in a different format for mm:dd:yy I guess)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2016 06:51 AM
You should be able to do like this:
var date = new GlideDate();
date.setValue(gs.beginningOfLastMonth());
var dateasint = date.toString().replace('-','');
gs.print(dateasint);
and if it need to "really" be a integer you can do like this:
var date = new GlideDate();
date.setValue(gs.beginningOfLastMonth());
var dateasint = parseInt(date.toString().replace('-',''));
gs.print(dateasint);