Date capture from email in inbound email action

Myana_Kavya
Tera Contributor

Hi,
I am triggering an inbound email action where below is my email body format

Myana_Kavya_0-1706530385443.png

 

Then am capturing this date in action as below

Myana_Kavya_1-1706530491285.png

Here, gdt is reading false value and assigning the same into field on my form.
Expected Result:
 gdt value must be 09:00 

Also, suggest me how can I read 12 hours time and convert it into 24 hours time format so that 09:00 PM should be taken as 21:00 as result.
Thanks
M.Kavya.

1 ACCEPTED SOLUTION

Tony Chatfield1
Kilo Patron

Hi, unfortunately screenshots do not allow the community to properly evaluate\test your issue and plain text is the best method to share this type of detail.

GlideDateTime can understand your date if you substring the appropriate details from your text,

but I'm not sure if there is a way to recognize AM/PM and the simple fix for this (if no one else has a better solution) would be to add 12 hours if the AM/PM reference is PM.

 

var testDate = 'REPORTED AT: 29-Jan-2024 09:00:00 AM UTC | 29-Jan-2024 02:30:00 PM IST';

var myDate = testDate.substring(testDate.indexOf(':') + 2, testDate.indexOf('UTC') - 4);
var amPM = testDate.substring(testDate.indexOf('UTC') - 3, testDate.indexOf('UTC') - 1)

var gdt = new GlideDateTime();
gdt.setValueUTC(myDate,'dd-MMM-yyyy hh:mm:ss');
if(amPM == 'PM') {
gdt.addSeconds(43200); // add 12 hours
}

gs.info(gdt);

 

View solution in original post

1 REPLY 1

Tony Chatfield1
Kilo Patron

Hi, unfortunately screenshots do not allow the community to properly evaluate\test your issue and plain text is the best method to share this type of detail.

GlideDateTime can understand your date if you substring the appropriate details from your text,

but I'm not sure if there is a way to recognize AM/PM and the simple fix for this (if no one else has a better solution) would be to add 12 hours if the AM/PM reference is PM.

 

var testDate = 'REPORTED AT: 29-Jan-2024 09:00:00 AM UTC | 29-Jan-2024 02:30:00 PM IST';

var myDate = testDate.substring(testDate.indexOf(':') + 2, testDate.indexOf('UTC') - 4);
var amPM = testDate.substring(testDate.indexOf('UTC') - 3, testDate.indexOf('UTC') - 1)

var gdt = new GlideDateTime();
gdt.setValueUTC(myDate,'dd-MMM-yyyy hh:mm:ss');
if(amPM == 'PM') {
gdt.addSeconds(43200); // add 12 hours
}

gs.info(gdt);