Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Filtering only time on a datetime field

Posted on by Microsoft Employee

Hi

Is it possible to filter a record with a time range on a datetime field?

I need to pick up all the lines that are inside a time range, between two dates, with only a datetime field...

Do I need to create a new field with the time section of the datetime field...!? (and update historic values with this new data)

Any suggestion?

Thank you in advance!

*This post is locked for comments

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Filtering only time on a datetime field

    yes, a Time field will be much faster for sure. This will be for sure the best way to do if you can create it in your table.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Filtering only time on a datetime field

    Thanks you.

    Hope that I will not have performance issues...

    I will try that way.

    If it will be too slow, I think that a new time field (as key), will be much faster, right?

    I need to filter several thousands of lines, 5 times (five ranges of times) in the same report...

    I'm wondering (another approach)  if I send all the lines between dates to the report (with no time range column), and then create there 5 tablix, with same data BUT with group filters based on the different time ranges... it will do the work faster?

    Thanks for the help!

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Filtering only time on a datetime field

    Ok now I understand your requirement. There’s no such possibily. I think you can solve that in few steps:

    1) filter your record from Date1,17.00T to Date2,18.00T

    2) loop through this set of records and mark the records that has the time in your desired range

    3) retrieve only the marked record (MARKEDONLY(true))

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Filtering only time on a datetime field

    Thank you.

    But I believe that I would get all the lines between the 00:00 of Date 1 and the 18:59 of Date 2. Is that correct?

    I need all the lines between, let's say, 1700T and 1800T, of each day between 030118D and 100118D.

    If want to pick the 050118 1730DT value but not the 050118 1000DT .

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Filtering only time on a datetime field

    You can filter the datetime field directly:

    YOURTABLE.SETRANGE(YOURFIELD,CREATEDATETIME(Date1,0T),CREATEDATETIME(Date2,18.59T));

    This sample filters between two dates (Date1 and Date2) in a certain time range.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 229,918 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans