How Can I filtered CustTable records with ModifiedDateTime equal to Today Date

Hello, I get all records of CustTable using select query in x++

CustTable custtable;

select * from custtable;

return custtable;

How I filtered CustTable records based on ModifiedDateTime equal to Today Date, Please help me?

Because there shouldn’t be any modifications done in future, all you need is to take records created since last midnight, i.e. you’ll compare them with the datetime value with the current date and empty time

For example:

custTable.ModifiedDateTime >= DateTimeUtil::newDateTime(currentDate, 0);

But you’re not done. You have to define what you mean by “Today Date”, because it’s different in different time zones. One option is always taking user’s time zone, therefore users in America and Asia (for example) will get different results. Or you my want to use company’s time zone. Or UTC. Or something else…

Database store these values in UTC, therefore if you have a local date, you have to convert it to UTC before running the query.

static void Job6(Args _args)
CustTable custtableLocal;
while select custtableLocal
if(DateTimeUtil::date(custtableLocal.modifiedDateTime) == today())


No, such code would fetch all customers, instead of just those few modified today. It would be a huge waste of time and processing time. The filter must be a part of the select statement.

While select custtable
where custTable.ModifiedDateTime >= DateTimeUtil::newDateTime(currentDate, 0)

Which is what I suggest, except that it misses the important piece that I pointed out - dealing with time zones. If currentDate isn’t in UTC, you’ll get meaningless results. And even if it is, jasdeep.singh didn’t confirm that he want the current date in UTC. Maybe he wants to work with users’ time zone.