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

How to get days from Date Formula datatype?

(0) ShareShare
ReportReport
Posted on by 607

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
    607 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
    607 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
    607 on at

    I use US notation then.

  • Suggested answer
    THE Italian Profile Picture
    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
    607 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

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,151

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,443 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,092 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans