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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Dynamic Date range in field type DateTime

(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!

  • Suggested answer
    IB-29041624-0 Profile Picture
    1,191 Moderator on at

    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.

  • RP at CML Profile Picture
    5 on at

    Hi Inge,

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

  • Suggested answer
    IB-29041624-0 Profile Picture
    1,191 Moderator on at

    You mean in the standard job queue setup page?

    Or what page and field do you want to use?

  • RP at CML Profile Picture
    5 on at

    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.

  • JES @ NLB Profile Picture
    7 on at

    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

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 743 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 546 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 332 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans