Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Unanswered

Taking the last day of the month in Date and Time Field

(0) ShareShare
ReportReport
Posted on by 5

We have a Calculated Field with Data Type:Date and Time (let's call it Y) . The value is based on another Date and Time field (X) and it needs to be the last day of the next month. For example

X = 12.4.2021, i need Y=31.5.2021

Version 1612 (8.2.1.176) (DB 8.2.1.176) on-premises

Can we do that?

  • RE: Taking the last day of the month in Date and Time Field

    Hello, I recommend you to do something like this in JavaScript, this does not require any library:

    var date = new Date();

    var lastday = new Date(date.getFullYear(), date.getMonth() + 1, 0); // the + 1 in the month refers to the actual month, if you want the last day of the next month you must put + 2.

    Thanks!

    Community Support Team - Esteban

    If this Post helps, then please consider Accept as solution to help the other members find it more quickly.

  • Pradeep Rai Profile Picture
    Pradeep Rai 5,490 Super User 2024 Season 2 on at
    RE: Taking the last day of the month in Date and Time Field

    Hi,

    If calculated field creation is not mandatory then 

    I would suggest to use some other business logic like Plugin, Script etc.

    These approach will be easier one.

    Thanks,

    Pradeep.

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

News and Announcements

Announcing Category Subscriptions!

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans