How is gs.daysAgoEnd calculated?

Jase2
Tera Contributor

I have a scheduled job that runs at 3:00 in the morning. In there it uses gs.daysAgoEnd. I'm not sure why, but when I run that later in the day it shows the day ends at 5:59:59 the next day. My question is does the time of day that you run gs.daysAgoEnd matter? When it runs at 3:00 will it still show the days ends at 5:59:59 the next day or the same day? I would think that it would be same day, but the results I get from the scheduled job seem to show that it uses the next day.

1 ACCEPTED SOLUTION

MrMuhammad
Giga Sage

Hi Jase,

 

The time doesn't matter it will return a date and time for the end of the day a specified number of days ago. 

for a quick test run below script in the background script after 10 - 15 mins interval and observe the date time in the output. Time will never change. 

var d = gs.daysAgoEnd(1);
gs.info(d);

 

Output - GMT date time string. 

Please mark this correct & helpful if it answered your question.

Thanks & Regards,
Sharjeel

 

Regards,
Muhammad

View solution in original post

7 REPLIES 7

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

Are you passing a int in that like 

gs.daysAgoEnd(int) 

this will decide which endDatetime to return? If it is not passed then it will give you next day date time by default.

SO i will say pass 1 in that.


Thanks,
Ashutosh

Jase2
Tera Contributor

Thanks Ashutosh.

In this case I am passing 0, but my question is the same no matter what int I pass. If I pass a 1 at 5:00, will I get a different result than if I pass a 1 at 7:00 on the same day?

HI,

Whenever you run over the day the time will not change it will be same.

Thanks,
Ashutosh

MrMuhammad
Giga Sage

Hi Jase,

 

The time doesn't matter it will return a date and time for the end of the day a specified number of days ago. 

for a quick test run below script in the background script after 10 - 15 mins interval and observe the date time in the output. Time will never change. 

var d = gs.daysAgoEnd(1);
gs.info(d);

 

Output - GMT date time string. 

Please mark this correct & helpful if it answered your question.

Thanks & Regards,
Sharjeel

 

Regards,
Muhammad