Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

comparison between different times

Shir Sharvit
Tera Contributor

Hey
How do I reverse the string - '18:00:00'
for the time 18:00:00
for comparison between different times.

 

Thanks. Shir

12 REPLIES 12

Yashsvi
Kilo Sage

Hi @Shir Sharvit,

please check below link:

https://www.servicenow.com/community/developer-forum/compare-two-date-times/m-p/1867573

 Thank you, please make helpful if you accept the solution.

Hey
My question is different
I have a string type field where '18:00:00' is entered manually,
I want to convert it to a field of type time

This will increase technical debt, better change data type to Date/ Time only.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi no
I need to compare the string '18:00:00' to the updated field.

ShirSharvit_0-1718715878512.png

The code: 

var updated = current.sys_updated_on.getDisplayValue();
    var updateTime = updated.split(' ')[1];
    var endTime = '18:00:00';
     var time = endTime - updateTime >= property;
 
The field - endTime is a string field and updateTime field  is a time field