- 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:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2016 07:03 AM
Yeah I was half-way through putting the date back together again when I saw Goran's response. Hey concatenation probably would have worked too though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2016 07:00 AM
Thanks so much Goran, your method worked perfectly.
I tried this method and almost had it! I just forgot to include the "toString()" method.
And thanks everyone for coming to my aid so quickly.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2020 02:40 PM
Old thread, but this helped me achieve what I was trying to do. I did notice that the Repeat Until [repeat_until] field on the Schedule Entry [cmn_schedule_span] table was an Integer Date type, and this was the only way I was able to set it:
var schedule_span_gr = new GlideRecord('cmn_schedule_span');
if (schedule_span_gr.get(SYS ID of RECORD));
{
var repeatUntilAsInt = date.toString().replaceAll('-', '');
schedule_span_gr.repeat_until.setValue(repeatUntilAsInt.toString());
schedule_span_gr.update();
}
Strangely, I couldn't set the value of the Integer Date field using an Integer, but somehow the String worked instead. There really wasn't a need to go to the Integer type at all.