Skip to main content
Business Central forum
Suggested answer

Dynamic Date range in field type DateTime

editSubscribe (0) ShareShare
ReportReport
Posted on by 5

Hi all,

I am wondering if you could advise on the below query?

 

How do we set a filter in a 'DateTime' type field to only include today, and the previous 6 days (most recent week’s-worth of data)?

In a ‘Date’ type field I would normally use the formula “T-7D..T” to get the required results, but this of course does not work in a 'DateTime' type field.

The exact scenario is setting Change Log Entries as a Job Queue Entry to run weekly, with a week's worth of data being reported. 

Thanks in advance for your help!

  • JES @ NLB Profile Picture
    JES @ NLB 5 on at
    RE: Dynamic Date range in field type DateTime

    Just read your post and I use something similar, (dayrange(-7,0)) with the "Matches" setting. It works for both date and date/time so far for me.

    In my case I use 30 days back and 3 days forward:

    pastedimage1682518745191v1.png

  • RP at CML Profile Picture
    RP at CML 5 on at
    RE: Dynamic Date range in field type DateTime

    Yes, in a standard job queue I want to run a report on Change Log Entries that only shows the last 7 days of changes. Change Log only has DateTime fields, no Date fields, so I am unable to use the standard filter I would use in a Date field (T-7D..T). I need to know the syntax for making an equivalent of this formula work in a DateTime field.

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,714 Super User on at
    RE: Dynamic Date range in field type DateTime

    You mean in the standard job queue setup page?

    Or what page and field do you want to use?

  • RP at CML Profile Picture
    RP at CML 5 on at
    RE: Dynamic Date range in field type DateTime

    Hi Inge,

    Thanks for your reply. Is it possible to achieve the results I need purely in the front-end?

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,714 Super User on at
    RE: Dynamic Date range in field type DateTime

    You can use the createdatetime function to generate the datetime for 6 days prior to today.

    learn.microsoft.com/.../createdatetime-function--datetime-

    First find the date today-6d and then use that date in the createdatetime function.

Helpful resources

Quick Links

What Motivates a Super User?

We know many of you visit the Dynamics 365 Community and Power Platform…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,068 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,591 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans