Skip to main content

for example, if today's month: 11.month-november, it should give me 31.10.2022

if its 10.month-october, it should give me 30.09.2022

I found out the solution.

I will just get the firstday of the month, it will give me 01.11.2022

and i will substract 1 day from that value, so it will give me the last of the last month.


Pls post code screenshot of solution.


i have created a csv file with all the last day of month. The bot read the content by month and year and get the last day. inputs are year and month.

 

year,month,end_of_month

2022, 01, 31.01.2022

2022, 02, 28.02.2022

..

2024, 01, 31.01.2024

2024, 02, 29, 29.01.2024

..

 

Consider the leap-year.

 

Regards

 


I hope the screenshot will assist you in determining the exact answer to the question above. 

 

 

 


Hi 

for example, if today's month: 11.month-november, it should give me 31.10.2022

if its 10.month-october, it should give me 30.09.2022

Hi ​@Semih 3318
@kisho already provided the best approach for your query. But if you’re looking to stretch and try another package use date-time utilities.

Please download this package first.

https://botstore.automationanywhere.com/bot/a2019-datetime-utilities

Datetime Utilities helps me a lot in most of my projects that require date manipulation and date processing.

Once you have downloaded and imported the package to your control room, check the overall solution below.

Overall Solution:
 

 


Hi ​@jeven.delacruz  thank you for your reply.

For this, datetime package in AA as my reply in my question is enough actually, no need to download a bot from botstore. 


Hi ​@Semih 3318 

You can calculate the last day of the previous month using both SQL and an Excel database query:

SQL Query

sql

SELECT 
DATEADD(DAY, -1, CAST(FORMAT(GETDATE(), 'yyyy-MM-01') AS DATE)) AS LastDayPrevMonth;
  • Retrieves the last day of the previous month by going to the first day of the current month and subtracting one day.

Excel Database Query

If you're using Excel as a database and querying through MS Access or Excel SQL engine, you can use the following query:

sql

SELECT 
DateSerial(Year(Date()), Month(Date()), 0) AS LastDayPrevMonth
FROM
Sheet1$];
  • Explanation:

    • DateSerial(Year(Date()), Month(Date()), 0): Computes the last day of the previous month by setting the day to 0 of the current month.

In both cases:

  • The SQL Query is perfect for typical SQL databases like SQL Server, MySQL, or others.

  • The Excel Query can be used for queries in tools like MS Access or directly manipulating Excel sheets using ODBC connections.


Reply