Tuesday, May 28, 2019

code to fetch records between time

public real getSalesCount12to1(TransDate _dateInvoice,inventlocationid _location)
{
    CustInvoiceTrans             custinvoiceTrans;
    InventDim                    inventDim;
    InventLocation               inventLocation;
     utcDateTime         rangeStart, rangeEnd;
     TimeOfDay           startTime, endTime;
    int                     i;

 select custinvoiceTrans where custinvoiceTrans.InvoiceDate == _dateInvoice;
    startTime   = str2time("12:00:00 pm");
    endTime     = str2time("1:00:00 pm");
    rangeStart = DateTimeUtil::removeTimeZoneOffset(DateTimeUtil::newDateTime(custInvoiceTrans.InvoiceDate,startTime), DateTimeUtil::getUserPreferredTimeZone());
    rangeEnd   = DateTimeUtil::removeTimeZoneOffset(DateTimeUtil::newDateTime(custInvoiceTrans.InvoiceDate,endTime),DateTimeUtil::getUserPreferredTimeZone());

    while select count(RecId) from custInvoiceTrans group  by InvoiceId
            join inventDim
            where inventDim.inventDimId == custInvoiceTrans.InventDimId
            && inventDim.InventLocationId == _location
             && (custInvoiceTrans.InvoiceDate == _dateInvoice)
            && (custInvoiceTrans.createdDateTime >= rangeStart && custInvoiceTrans.createdDateTime < rangeEnd)
        {
            i++;
        }
        AWD_SaleshourlyTmp.NoOfInvoices12pm = i;//str2int(custInvoiceTrans.InvoiceId);


    return AWD_SaleshourlyTmp.NoOfInvoices12pm;

}

No comments:

Post a Comment