Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Unanswered

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

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?

Categories:
  • 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

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,537 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,520 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans