Skip to main content

Notifications

Announcements

No record found.

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!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans