Getting 1970-01-03 12:13:00 as a output when accessing values from glideduration type field.

Mark Wood
Tera Contributor

Hello Experts,

I have created a field named "repeat" with a data type of "glide-duration." My requirement is to access these values in datetime format. How can I achieve this? I have attached a screenshot below for reference. Please guide me on this. Thank you.

9 REPLIES 9

When you get the value of a date/time field in a server script (Business Rule, Script Include,...) it will be in the system format (and UTC timezone) which expresses the time in the 24 hour format to alleviate this concern. All of the GlideDateTime methods use the same time format

https://docs.servicenow.com/bundle/vancouver-api-reference/page/app-store/dev_portal/API_reference/G... 

Hello @Brad Bowman ,  

If I have a "time" type field named as due time, how can I access its value? If that field's value matches the current time, I want to send a notification.

In a server script, both the value of a time type field, and the getTime method of the GlideDateTimeAPI express the system time in the format 1970-01-01 hh:mm:ss so this script

 var nowt = new GlideDateTime().getTime();
 gs.addInfoMessage( 'now: ' + nowt + ' time field: ' + current.u_time);

Run at 16:05 EDT with a value of 12:50:13 (Eastern Time in my User Profile preferences) showing in the time field displays the message

now: 1970-01-01 20:05:00 time field: 1970-01-01 17:50:13

 

 @Brad Bowman  sorry I did not get you properly what exactly you are telling to me.how can we check due time matches with our current or not?if its matches we have send notification on due time do I need write script or using configuration I can achieve this .please guide me on this .to be honest spent a lot of time on it but still not able to solve it.

This depends on what you are doing to trigger this action to compare - is there a timer or Run Script on a workflow, a step in a Flow, or are you running a scheduled job,...

You can send notifications with an event, so the above understanding of getting the value of the now time and a time field is necessary to know when to fire the event.

https://docs.servicenow.com/bundle/vancouver-platform-administration/page/administer/notification/ta... 

 

https://docs.servicenow.com/bundle/vancouver-build-workflows/page/administer/platform-events/concept...