- 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-21-2016 09:03 AM
Well at least for once, I won

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2016 09:06 AM
I sort of felt like I was writing an exercise for one of my old freshmen computer science courses.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2016 09:08 AM
Been there, done that
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2016 11:23 AM
Abhinary Hello,
thank you for reply. I have one question to the result of your code,
It is keeping to change the date and time of converted string, i.e. for the date which i get from my email (in my example email it is Thursday, July 14, 2016 11:00:43 PM)
the resulting DATE/TIME record is - 2016-07-15 08:00:43
Maybe you can suggest how to prevent the change of the initial date and time from string?
also,
the email is:
Hi Team,
tests are as follows:
Thursday, July 14, 2016 11:00:43 PM
Check 1
Browse Site http://
Try 1
............Title of page returned: Example
Elapsed time 17.0622773 seconds ...
this is how i'm getting the date/time
var testDate = email.body_text.substring(email.body_text.indexOf('follows:')+8, email.body_text.indexOf(' PM')+3).trim();
current.u_date = testdate;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2017 04:19 AM
Hi Abhinay,
I tried the following code in Scripts-Background in Kingston version:
var t = Date.parse("2017-12-26T19:50:38.794+05:30")
gs.info(t);
It gives me NaN.
How do I parse this date with timezone and create GlideDateTime object from it?
Thanks!