Skip to main content

Notifications

Small and medium business | Business Central, N...
Answered

[Newbie] Get max days from DMY2Date function.

Posted on by 60

Hello,

I would like to insert the maximum value of the integer in the day of DMY2Date function but cannot seem to figure it out.

Example:

Month1 is an integer and it is 3 and i know the last value for the day is 31 since it is march, but i want it to "generate" the last day of each selected month.

So if I use Date1 and i only have the year and the month, i want to get the last day of the month:

Month1 := 3

year1 := 2023
//To get the last day of the selected month and year
Date1 := DMY2Date(Maxvalue,Month1,Year1)
//Date1 becomes equal to 31/3/2023

Sorry if the question makes no sense and I will be removing it if it makes no sense,
Thank you

  • Charbel Hleyhel Profile Picture
    Charbel Hleyhel 60 on at
    RE: [Newbie] Get max days from DMY2Date function.

    Thank you a lot!

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: [Newbie] Get max days from DMY2Date function.

    Hi,

    You can try below method to get the last date of the month

    LastDate := CALCDATE('CM',DMY2DATE(1,Month1,Year1)));

    Thanks.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,056 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans