
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 08:37 AM
Hi all,
I am working with datetime fields. I use a script to fill these fields but I found a bad behaviour.
I try to set value as 01/10/2024 (first of october) but systems set as 10/01/2024 (tenth of january).
In my script:
var date ="2024/10/01 00:00:00" (introduced by user and set here trying to be more clear)
var a = new GlideDateTime();
a.setDisplayValue(date, "yyyy-MM-dd HH:mm:ss")
Later on a gliderecord
...
gr.setValue("start",a);
gr.insert();
Could anyone have same problem in past?
Regards.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 12:42 AM
Always fun to fight with date/time, until it gets frustrating.
Can you see if this works for you (I am unable to reproduce your issue, so hoping it helps).
var userDate = "2024-10-01 00:00:00"; // Ensure consistent format yyyy-MM-dd
var a = new GlideDateTime();
a.setValue(userDate); // Use setValue() to directly set the value in ISO format
var grIncident = new GlideRecord('incident');
grIncident.initialize();
grIncident.setValue('start_date', a); // Set the GlideDateTime object directly
grIncident.insert();
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 08:44 AM
Hi @Jose MMR
Use below script
Please mark this response as Correct and Helpful if it helps you can mark more that one reply as accepted solution
Thanks
Eshwar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 12:21 AM
Hi Eshwar Reddy
Thanks for your answer. Unfortunatelly the problem continues. I can transform dates in script but in the moment to set to field, changes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 12:42 AM
Always fun to fight with date/time, until it gets frustrating.
Can you see if this works for you (I am unable to reproduce your issue, so hoping it helps).
var userDate = "2024-10-01 00:00:00"; // Ensure consistent format yyyy-MM-dd
var a = new GlideDateTime();
a.setValue(userDate); // Use setValue() to directly set the value in ISO format
var grIncident = new GlideRecord('incident');
grIncident.initialize();
grIncident.setValue('start_date', a); // Set the GlideDateTime object directly
grIncident.insert();
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark