Monday, May 15, 2023

Day Deduct From Given Date

Hi, 

In this post we will see how to a day from given date time field and for demo purpose used static methods of class DateTimeUtilClass. 

Note: CG_DeductDaysFromDateTime is a runnable class. 

public static void main(Args _args) 

    {    

        utcdatetime dateTime; 

        date        datePart; 

        TimeOfDay   timePart; 

        int         monthPart; 

  

        dateTime = DateTimeUtil::getSystemDateTime(); 

  

        // Deducts one day from current day 

        datePart = DateTimeUtil::date(dateTime) - 1; 

        timePart = DateTimeUtil::time(dateTime); 

        dateTime = DateTimeUtil::newDateTime(dateParttimePart); 

        info(strFmt("New date time is %1", dateTime)); 

  

        dateTime = DateTimeUtil::getSystemDateTime(); 

        dateTime = DateTimeUtil::addDays(dateTime , -1); 

        info(strFmt("New date time is %1", dateTime)); 

    }  

//Substract 1 day to Actual system date DateTimeUtil::addDays(DateTimeUtil::getSystemDateTime(),-1) //Add 1 Month to Actual system date DateTimeUtil::AddMonths(DateTimeUtil::getSystemDateTime(),-1)

No comments:

Post a Comment

Automating Consolidate Account Updates for New Voucher Transactions in D365 Finance and Operations

  Ensure the  Consolidate Account  field is automatically updated for all new voucher transactions based on the  Consolidate MainAccount set...