Last date of the month
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
17-04-19 05:19 PM
Hello,
How to get last day of the month, for example the given date is 16.08.2019 and i would like to get 31.08.2019 in return.
Any ideas and suggestions appreciated.
BR
Zahib
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
17-04-19 11:34 PM
Hi Zahib,
To get the last day of month you'll need the following data items as Number
Data Item to store the current month: Month -> to calculate the month you have to use a calc stage and write the expression FormatDate(Today(),""MM"")
Data Item to store the year: Year -> to calculate the year you have to use a calc stage and write the expression FormatDate(Today(),""yyyy"")
Data item to store the days of the month : NumDays
Add a code stage that:
takes as Input : Month and Year
gives an Output : NumDays
On the code tab write : NumDays = System.Datetime.DaysinMonth(Year,Month)
Attached find an image of the flow
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
18-04-19 03:20 AM
Hi Zahib,
Your requirement can be achieved using native functions in Blueprism.
Create the following data items:
1. Of Date type, which stores input date.
2. Of Number type, which stores the last date of the month.
3. Of Date type, which stores the required output date.
Now add a calculation stage with the expression: DateDiff(9, [Date], AddMonths([Date], 1))
Another calculation stage with the expression: MakeDate([Last Day of Current Month], FormatDate([Date], ""MM""), FormatDate([Date], ""yyyy""))
First function will calculate the number of days difference between two dates:
1. Input date
2. Date of the same day in the next month.
Second calculation will calculate actual last date of that month.
Please find the attachments below for better understanding. Hope it helps.
Thank you.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
18-04-19 02:56 PM
Thank you much to both of you 🙂
