- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2019 02:07 AM
I have the below script where I'm getting first and last date of the month but not in yyyy-mm-dd format,
var nowDateTime = new GlideDateTime('2019-05-10');
var date = nowDateTime.getDate();
var month = date.toString().split("-")[1];
var year = date.toString().split("-")[0];
var FirstDay = new Date(year, month-1, 1);
var LastDay = new Date(year, month, 0);
gs.info(FirstDay);
gs.info(LastDay);
Output:
*** Script: Wed May 01 2019 00:00:00 GMT-0700 (PDT)
*** Script: Fri May 31 2019 00:00:00 GMT-0700 (PDT)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2019 03:19 AM
hi ,try with below code
var nowDateTime = new GlideDateTime('2019-05-10');
var date = nowDateTime.getDate();
var month = date.toString().split("-")[1];
var year = date.toString().split("-")[0];
var FirstDay = new Date(year, month-1, 1);
var LastDay = new Date(year, month, 0);
var first= new GlideDateTime(FirstDay);
var last = new GlideDateTime(LastDay);
gs.info(first);
gs.info(last);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2019 03:19 AM
hi ,try with below code
var nowDateTime = new GlideDateTime('2019-05-10');
var date = nowDateTime.getDate();
var month = date.toString().split("-")[1];
var year = date.toString().split("-")[0];
var FirstDay = new Date(year, month-1, 1);
var LastDay = new Date(year, month, 0);
var first= new GlideDateTime(FirstDay);
var last = new GlideDateTime(LastDay);
gs.info(first);
gs.info(last);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2019 03:35 AM
I'm getting output like below, how to get only date not time
*** Script: 2019-05-01 07:00:00
*** Script: 2019-05-31 07:00:00
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2019 03:36 AM
sorry i forgot to mention use this
gs.info(first.getDate());
gs.info(last.getDate());
to print