Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

computed column of view - How to return date difference in days between todays date and record creation datetime

(0) ShareShare
ReportReport
Posted on by 438

HI All,
I am implementing a requirement where I want to return date difference between creation date time and today's date.  have tried like below but not getting expected result. Please suggest the approch. 

 private static server str compColumnApprovalDays()
    {
      

        #define.CompView(AllPOLinesView)
        #define.CompDS(PurchLine)
        #define.FieldCreatedDateTime("CreatedDateTime")

        str todayDate = strFmt("%1", DateTimeUtil::getToday(DateTimeUtil::getUserPreferredTimeZone()));

        str fromDate =  SysComputedColumn::returnField(tableStr(#CompView), identifierStr(#CompDS), fieldStr(#CompDS, #FieldCreatedDateTime));

        str test = SysComputedColumn::getDateDiff(fromDate,todayDate);

      

        return test;
    }

in DB i am able to see the values as shown below.
pastedimage1673328724803v1.png

  • Verified answer
    Vijay Yelmame VY Profile Picture
    Vijay Yelmame VY 438 on at
    RE: computed column of view - How to return date difference in days between todays date and record creation datetime

    This is resolved. Please don't invest your time.


    private static server str compColumnApprovalDays()
    {
    
        return SysComputedColumn::getDateDiff(
                    SysComputedColumn::returnField(tableStr(AllPOLinesView), identifierStr(PurchLine),
                                            fieldId2name(tableNum(PurchLine),fieldNum(PurchLine, CreatedDateTime))),
                SysComputedColumn::getCurrentUtcDate(),
            SysComputedColumnDatePart::Day);
       
    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,759 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,468 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans