gs.daysAgoStart(0) vs gs.beginningOfToday()

barakpinch
ServiceNow Employee
ServiceNow Employee

Date input fields and fields values (labels) for filter component:

I'm using the value "javascript:gs.daysAgoStart(0)" (before Today) which is not translated correctly in snDateChoiceElement.js to "before Today" because snDateChoiceElement.js looks for values from a list, and "javascript:gs.daysAgoStart(0)" is not included there.

Instead, there is the 'before"javascript:gs.beginningOfToday()"' under Today filter. If I replace "javascript:gs.daysAgoStart(0)" with "javascript:gs.beginningOfToday()" then I get the desired value (label of "Today"). 

Why are the *Ago*(*) format not supported and is there a java\javascript utility that translates the *Ago*(*) values to *beginningOf*(*) values?

Thanks

1 REPLY 1

Omkar Mone
Mega Sage

Hi

Maybe this "Moment.js" library of javascript will help you get going with this concern of yours. Refer to the link below.

https://momentjs.com/

 

Or in Javascript do the following code :-

 

var date = new Date();

date ; //# => Fri Apr 01 2011 11:14:50 

date.setDate(date.getDate() - 1);

date ; //# => Thu Mar 31 2011 11:14:50 

 

Mark Correct or Helpful if my answer helped you.

 

Regards,

Omkar Mone.

www.dxsherpa.com