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...
Answered

How to get days from Date Formula datatype?

(0) ShareShare
ReportReport
Posted on by 625

Hi All,

I want to get the number of days from dateformula datatype, like 1M = 31D, 1Y = 365D, 1W = 7D  How can i achieve this ?

Also whats the difference between 28D and D28?

The result of : 

  1. CalcDate('-28D',Today()) = 2/29/2020. 
  2. ClacDate('-D28',Today()) = 2/28/2020 , how?   Please explain in detail?
I have the same question (0)
  • Suggested answer
    keoma Profile Picture
    32,729 on at

    DATE2DMY(TODAY,1) gives 28.

    DATE2DMY(CALCDATE('CM',DMY2DATE(01,3,2020)),1) gives 31: no. of days in 03/2020

    CALCDATE('1M',TODAY) calcs the current day + 1 month: 3/28/20 -> 4/28/20

    CalcDate('-28D',Today()) calcs today - 28 days. today = 3/28/2020 -> result = 2/28/2020

    CalcDate('-D28',Today()) calcs the nearest 28th day in the past.
    today = 3/28/2020 -> result = 2/28/2020, because today is not yet finished, so the next 28th in the past is last month, means february.
    today = 3/29/2020 -> result = 3/28/2020, because that is the nearest 28th in the past according 3/29/2020.

    CalcDate('D28',Today()) calcs the nearest 28th day in the future.
    works like above.

  • AXBOY Profile Picture
    625 on at

    I tried the following cases and the following results which doesnt quite really match what you said:

    Queries :

    Today() = 3/29/2020

    For X = 1 to 29, CalcDate('-DX',Today()); Output = 3/X/2020 ; It calcs the Xth day of the current month.

    For X = 30 & 31, CalcDate('-DX',Today()); Output = 2/29/2020

    For X = 1 to 30 ,  CalcDate('+DX',Today()); Output = 4/X/2020 ; It calcs the Xth day of the next month,which is correct like you said.

    But for X=  31, CalcDate('+DX',Today()); Output = 3/X/2020 ; It calcs the Xth day of the Current month

    PLEASE HELP!

  • Suggested answer
    keoma Profile Picture
    32,729 on at

    do you use the US or the GB date notation?

  • AXBOY Profile Picture
    625 on at

    How  to check that date notation?

  • keoma Profile Picture
    32,729 on at

    29/3/2020 is GB (english and global) notation

    3/29/2020 is US notation

  • AXBOY Profile Picture
    625 on at

    I use US notation then.

  • Suggested answer
    THE Italian Profile Picture
    Microsoft Employee on at
  • Suggested answer
    keoma Profile Picture
    32,729 on at

    i modified my answer from yesterday, 3/28/2020, and described in detail the results. should be helpful.

    so, my results from yesterday are correct and yours from today also.

  • AXBOY Profile Picture
    625 on at

    @FranzKalchmair

    Hi,

    You said, CalcDate('-D28',Today()) ; Output : 2/28/2020,

    But its giving : 3/28/2020, its returning the 28th of the current month not the previous month.

    Only for For X = 30 and 31, CalcDate('-DX',Today());  i am getting Output = 2/29/2020

    and for X =1-29,CalcDate('-DX',Today()); Output = 3/X/2020 ; It calcs the Xth day of the current month.

    Please Help!

  • Verified answer
    keoma Profile Picture
    32,729 on at

    if the current date of your windows system is 3/28/2020 or e.g. 3/27/2020, then the result of CalcDate('-D28',Today()) is 2/28/2020. if the current windows date is later, e.g. 3/29/2020, then the result is 3/28/2020.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,958 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,101 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 959 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans