Hi,
I'm adding a grid field into the interface, involving columns from a record type. There is one column called updatedDateTime, and what I want to query is data which were updated within the last 2 days, that means now() - updatedDateTime < 2 days (or 48hours) or . The column format is now dd/M/yyyy hh:mm a
I cannot find out how to write in the filter parameter of a!gridField() so please help!
Discussion posts and replies are publicly visible
you can directly use now()-2 as a value for the filter. Hope it will work
Do not subtract an integer directly from now() it is a very bad idea. You can use now()-intervalds() by providing the correct range. In this case, we don't need any of these tho as our use case is to get data from the last 2 days. So we need to check from the start of the day till now. Check the below example -
a!queryLogicalExpression( operator: "AND", filters: { a!queryFilter( field: "createdOn_dtm", operator: "<", value: now() ), a!queryFilter( field: "createdOn_dtm", operator: ">", value: datetime(year(now()), month(now()), day(now())-2, 00, 00, 00, 00) ) } )
Thanks a lot for helping!!! It works the way I wanted! just a small change is that I need cases which are closed in recent 2 days and unclosed cases, so my code was:
a!queryLogicalExpression( operator: "OR", filters: { a!queryFilter( field: "closedDate", operator: "is null" ), a!queryFilter( field: "closedDate", operator: ">", value: datetime(year(now()), month(now()), day(now())-2, 00, 00, 00, 00) ) } )