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

Community site session details

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

[Newbie] Get max days from DMY2Date function.

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator 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.

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

    Thank you a lot!

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

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,696 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,512 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans