Sunday, January 23, 2022

Ranges on DateAndTime Field


static void CreatedDateTimeRange(Args _args)
{
    Query                   query;
    QueryRun                queryRun;
    QueryBuildDataSource    qbds;
    QueryBuildRange         qbr;
    CustTable               custTable;
utcDateTime             userDateTime;

hours = 8;
    

userDateTime = DateTimeUtil::addHours(DateTimeUtil::getSystemDateTime(),hours);
 
    // Instance the class Query
    query =  new Query();
 
    // Add DataSource to Query
    qbds = query.addDataSource( tableNum(CustTable));
 
    // Add a range
    qbr = qbds.addRange( fieldNum(CustTable,CreatedDateTime));
 
    // Set range value
    qbr.value(SysQuery::range( "01/01/2012","30/12/2012" ));

or

qbr.value(SysQuery::range(userDateTime , DateTimeUtil::getSystemDateTime()));
 
    // Run Query
    queryRun = new QueryRun(query);
 
    // Retrieves the next record from the query.
    while(queryRun.next())
    {
        // Get Result
        custTable = queryRun.get( tableNum(CustTable));
 
        // Show AccountNum
        info(custTable.AccountNum);
    }
}

No comments:

Post a Comment

Sample Dialog Syntax - 1

 class AffiliationAutoAssignment extends RunBaseBatch {     // 1. Class Declaration and Pack variables     #define.CurrentVersion(1)     #de...