# How to get the Last day of any month?

**URL:** <https://forums.pega.com/t/how-to-get-the-last-day-of-any-month/2523>\
**Category:** User Experience\
**Tags:** 7-2-2, dev-designer-studio, user-experience, data-management\
**Created:** [April 25, 2022, 3:02pm UTC](https://forums.pega.com/t/how-to-get-the-last-day-of-any-month/2523 "2022-04-25T15:02:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PriyabrataBiswas](https://avatars.discourse-cdn.com/v4/letter/p/258eb7/32.png) [@PriyabrataBiswas](https://forums.pega.com/u/PriyabrataBiswas)\
**Post date:** [April 25, 2022, 3:02pm UTC](https://forums.pega.com/t/how-to-get-the-last-day-of-any-month/2523/1 "2022-04-25T15:02:13Z")

</div>

From a service I am getting date like this yyyyMM for example 199804. We need to append Last day of the month with this date.

Any idea how to do that?

I didn’t found any inbuilt function for the same?

I am looking for any inbuilt function for that as I dont want to add conditionally date in a DT or activity.

---

<div class="post-metadata">

**Author:** ![PIYUSH\_SINHA](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/piyush_sinha/32/23409_2.png) [@PIYUSH\_SINHA](https://forums.pega.com/u/PIYUSH_SINHA)\
**Post date:** [April 28, 2022, 7:23pm UTC](https://forums.pega.com/t/how-to-get-the-last-day-of-any-month/2523/2 "2022-04-28T19:23:36Z")

</div>

@Priyabrata_Biswas

I don’t think there is any OOTB Function to achieve that. You need to write your own function for this.

There are plenty of options available to write that java code.

---

<div class="post-metadata">

**Author:** ![PriyabrataBiswas](https://avatars.discourse-cdn.com/v4/letter/p/258eb7/32.png) [@PriyabrataBiswas](https://forums.pega.com/u/PriyabrataBiswas)\
**Post date:** [May 4, 2022, 4:00am UTC](https://forums.pega.com/t/how-to-get-the-last-day-of-any-month/2523/3 "2022-05-04T04:00:52Z")

</div>

I found the solution like this –

@addTodate(@addToDate((“date string”+“01”),0,1,0),-1,0,0)

How it is working:

Here “date string” is in format yyyyDD for example 199804

1. First append “01” to make it 19980401

2. Inner function to add one month to make it 19980501

3. Outer function to minus 1 day to make it 19980430
