- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2022 02:19 PM
HI All,
In my code I am receiving a JSON package and one of the values I receive is a date time in string format.
Example:
"PurchaseDateTime":"17\/08\/2022 16:50:00",
I am trying to assign this to a DateTime Field and my end result is always 2022-08-17 00:00:00
Assignment Code:
var bookingDateTime = data.Booking[i].PurchaseDateTime; //String Value From JSON example receipt 17\/08\/2022 11:30:00
bookingDateTime = bookingDateTime.replace(/\\/, ''); //lets get rid of the '\' from the string
gs.info("<BP> cpx_gsadmin_handler - processResponse: Purchase Date Time: " + bookingDateTime, "cpx_gsadmin_handler");
grBooking.purchase_date_time.setDisplayValue(bookingDateTime, "dd/MM/yyyy HH:mm:ss"); //TEST VALUE ASSIGNMENT 17\/08\/2022 11:30:00
the gs info output for the time formatted is as follows:
<BP> cpx_gsadmin_handler - processResponse: Purchase Date Time: 17/08/2022 16:50:00
The date is getting set correctly but not the time...
Any assistance would be great!
Thanks
Solved! Go to Solution.
- Labels:
-
Script Debugger
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 02:40 PM
To resolve this issue I ended up splitting the datetime string and then applying them to a GladeDate and GlideTime separately. I was then able to manipulate the objects and merge them into a GlideDateTime object.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2022 02:28 PM
Hi Brandon,
Check if this could help.
Need help with date/time field converting to string
Mark Correct or Helpful if it its helps.
***Mark Correct or Helpful if it helps.***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 02:40 PM
To resolve this issue I ended up splitting the datetime string and then applying them to a GladeDate and GlideTime separately. I was then able to manipulate the objects and merge them into a GlideDateTime object.