- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2016 08:20 AM
Hello, i have an inbound email action to create a new records from emails.
The email body_test contains string date, presented in such way, for example - Thursday, July 14, 2016 11:00:43 PM
I'm extracting that date, and i need it to be inserted in the DATE/Time field [u_date] (so for example - 2016-07-14 23:00:43)
Do you have suggestion on how to do that?
Any input will be welcomed, because i'm lost with that
Thank you!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2016 08:52 AM
Oh wow, that is a lot of coding. If I am not wrong, this can be achieved in 4 lines
var sec=Date.parse("Thursday, July 14, 2016 11:00:43 PM");
var gdt = new GlideDateTime();
gdt.setNumericValue(sec);
gdt.getDisplayValue(); //this will give you the date in your format

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2020 06:02 AM
I would use a regular expression with the match() method. Something like this:
var dateStr = '20200723T080000';
var patt = /^([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})/;
var list = dateStr.match(patt);
if (list) {
gs.info("year=" + list[1]);
gs.info("month=" + list[2]);
gs.info("day=" + list[3]);
gs.info("hour=" + list[4]);
// you get the idea
}