how to retrieve data from two and three days ago?

rjp
Tera Expert

Hi Gurus,

Is it possible to retrieve data that has an updated date equal to Yesterday AND two days ago AND three days ago.

I see there are built-in options for today, yesterday, last 7 days etc, but that goes back to far.  I just need for the past three days.  

Let me know if you think this is possible.

Thanks,

Rob

1 ACCEPTED SOLUTION

try now

 

usrCount = new GlideRecord("sn_imt_quarantine_unanswered_health_status_user");
usrCount.addEncodedQuery('u_unanswered_dateRELATIVELT@dayofweek@ago@3^u_unanswered_dateRELATIVEGT@dayofweek@ago@4');
usrCount.query();

var userArray = [];
while(usrCount.next()){

usrCount2 = new GlideRecord("sn_imt_quarantine_unanswered_health_status_user");
usrCount2.addEncodedQuery('u_unanswered_dateRELATIVELT@dayofweek@ago@2^u_unanswered_dateRELATIVEGT@dayofweek@ago@3^u_person=usrCount.u_person.name');

usrCount2.query();

while(usrCount2.next()){


gs.log('here1');
gs.log(usrCount2.u_person.name);
userArray.push(usrCount.sys_id.toString());
}

}

View solution in original post

35 REPLIES 35

I got it..

 

userArray has the sys_Id and you are passing this sys_Id to a Person Name.

Instead you have to try passing the Name to Person Name which will return the records.

 

Try running your script in script - Background by printing userArray[0] value and make sure the result shows name instead of '0b34XXXXXXX'.

 

 

Regards,

Sravan

 

Even with script that returns the name value, it still returns NULL for the records from the table.

I still think it has to script include, maybe its not defined properly.

THank you for all your help with this.

 

 

find_real_file.png

 

find_real_file.png

Your Script Include name should be get3DaysAgoData. Please remove brackets () at the end of script include name and try again.

 

Please Mark it Correct & Helpful if it helps you.

Regards,
Sravan.

rjp
Tera Expert

I don't know why it doesn't pick up yesterdays transactions, could it have something to do with date formats are not compatable?

Hi Rjp,

I guess its something related to timezone difference.Because for me its showing the report as working fine.

And yes the date time format might be the issue and timezone difference.

The filter is correct as i tested in my PDI. There must be data issue in your instance.

Can you check for other days( 4 days, 3days and 2 days ) it must come. 

 

 

Please mark my answer Correct and Helpful.

Thanks,

CB

Thanks,

CB