Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

How to get missing date from given date range

Posted on by 135

Hi there,

I am having a dialog with from date and two date dialog fields.

On MyCustom table i am having transaction on the basis of date.

If i am selecting date range of 1/12019 - 31/1/21019 and click on OK button, how can i find out which date record is missing in mycustom table.

How can i achieve it? 

*This post is locked for comments

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to get missing date from given date range

    Add method existsForEmployeeAndDate in your table, and call it with a date and employee id. Otherwise the code is identical to my previous answer.

    This is how you will get missing dates for an employee. Is it what you were looking for?

  • Maahi P Profile Picture
    Maahi P 135 on at
    RE: How to get missing date from given date range

    Hi Nikolaos,

    I have a table with below field.

    WorkerPersonnalNumber, WorkerName, AttendanceDate, Status.

    There will be some missing records in this table for employee who are absent.

    I need to bring the records,  missing date for that employeeID.

    Thanks

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to get missing date from given date range

    I don't understand your question. How is the worker rec id related? For sure you can search by date and worker if you want to. Please remember that we know only what you share. So far you haven't shared anything related to worker, but now you ask about it. How could we know?

  • Maahi P Profile Picture
    Maahi P 135 on at
    RE: How to get missing date from given date range

    Thanks Nikolaos , It worked.

    One more thing i need to ask, 

    i want to search it on the basis of missing date and hcmworkerrecid.

    i have to run my while select on my custom table, and if there is no records then my no loop will be there for that record.

    how  can i fetch missing date under while select? 

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to get missing date from given date range

    The exact solution depends on your custom table. What is the field name, data type etc. But let's assume your table has method existsForDate which tells if there is a record for the given date.

    Then your code would look something like this:

    Date fromDate = dialogFieldFromDate.value();
    Date toDate = dialogFieldToDate.value();
    
    while (fromDate <= toDate)
    {
        if (!MyTable::existsForDate(fromDate))
        {  
            info(strFmt("No record for date %1", fromDate));
        }
        fromDate += 1;
    }

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans