DateRange in X++ query


I need to select some data based on last successful run of a particular batch job. for Example:

select CustTable

where CustTable.createdDateTime > ‘last run date of the bacth’ && CustTable.createdDateTime < systemDateGet()

I need to get all customers that were created since the batch ran last time until current run.


  1. How do i get the last run date for a batch job?
  2. How do i mention the date range so that i don’t miss any records?

You should also take into account that the batch failed, which can be resolved by including a condition for batch status. Also somebody may have removed batch history, which would ruin your logic completely. If this is an actual risk, you would have to save the information somewhere else, e.g. in a separate table or even to flag customers which have been already processed. Or creating a record could insert a record to a queue that would be processed by the batch.

Thanks martin, its better to rethink this logic. Thanks for your valuable input.