web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Filtering records based on date using OData API

(1) ShareShare
ReportReport
Posted on by 244
Hi Team,

How do I filter records based on DATE in OData API in Business Central.

I have a API where I need to filter on postingdate. However when tried eq, gt, lt the result is not filtering properly.

Eg : http://xxx:7048/BC220/api/v2.0/companies(xxxx)/journals(xxx)/journalLines?$filter=postingDate eq 2024-01-10

Above API is not returning any records. However record is available for the mentioned posting date.

Thank
I have the same question (0)
  • Suggested answer
    Shrey Chauhan Profile Picture
    284 on at
    Hello,

    Here's the correct filter to get the data related to specific posting date :



    Hope this help's to solve your queries.

    May other expert's give you better solution's.

    Thank You,
    Shrey Chauhan
  • Suggested answer
    Rajaneesh H Profile Picture
    244 on at
    Hi Shrey & others,
     
    I have done the same thing as you mentioned but still not getting the expected result. see the screenshot below. Date is not filtering properly for 2024-01-02.
     
  • Suggested answer
    YUN ZHU Profile Picture
    95,329 Super User 2025 Season 2 on at
    Hi, this is a bit strange, the method mentioned by Shrey should have no problem. I also tested it.
    Endpoint: https://api.businesscentral.dynamics.com/v2.0/c8558e71-6ad8-4fcd-9f29-3ca165b41bbe/Sandbox223/api/v2.0/companies(554f4f15-9c8e-ee11-be3e-6045bde96b9a)/salesOrders?$filter=postingDate eq 2023-04-02
    Since this is the On-Pre version, I suspect this may be a date format issue with the server, but I'm sorry I'm not sure.
    Hopefully other experts can give you better advice.
     
    Thanks.
    ZHU
  • Suggested answer
    Rajaneesh H Profile Picture
    244 on at
    Hi Zhu,
     
    Thanks for the response. Is there any way we can format the date in the API? If yes, can you suggest me any document link or any other video link?
     
    I also noticed that, if I filter for 2024-01-10 date , it is displaying 2024-01-09 records. i.e., day-1 records!

    Thanks Again
    Rajaneesh H
  • Suggested answer
    Gerardo Rentería García Profile Picture
    25,154 Most Valuable Professional on at
  • Verified answer
    Rajaneesh H Profile Picture
    244 on at
    Hi All,

    After doing some permutations and combinations, I finally able to crack some solution for this problem which is occurring especially in On-Premise BC.

    Instead of filtering date like this

    http://xxxx:7048/B220/api/v2.0/companies(xxxxx)/journals(xxx)/journalLines?$filter=postingDate eq 2024-01-02

    try this

    http://xxxx:7048/B220/api/v2.0/companies(xxxxx)/journals(xxx)/journalLines?$filter=postingDate eq 2024-01-02T10:00:00.00Z

    it worked!! I have tested several scenarios including range filters and tests passed.

    Happy Coding!!

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,226

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,047 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,257 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans