Find the first and last day of the previous month

Hello, in a study I did in studiox, I want to take the last day of the previous month according to the current date and write this date information in the relevant field in the application. Similarly, I need to print the first day of the previous month in a different field. It should do this dynamically by finding the correct dates every time I do the work. With which activities can I do it?

@yesim.aktas

check the thread

HI @yesim.aktas
DateTime LastDate=New DateTime(Now.Year,Now.Month,1).AddDays(-1).ToString("dd/MM/yyyy")
Regards,
Arivu

Hi @yesim.aktas

Get first date of Previous Month:
str_firstdate = New DateTime(Now.Year, Now.Month, 1).AddMonths(-1).ToString("dd/MM/yyyy")

Get last date of Previous month:
str_lastdate = New DateTime(Now.Year, Now.Month, 1).AddDays(-1).ToString("dd/MM/yyyy")

Hope it helps!!

HI,

How about ModifyDate activity as the following?

Sample
NewBlankTask20240507-1.zip (50.1 KB)

Regards,

hi yoiche, the day format I need to enter in the app should be like this: DD.MM.YYYY
How can I update this in this event you’re talking about?
Thank You

Hi,

Can you try as the following?

Sample
NewBlankTask20240507-1 (2).zip (50.1 KB)

Regards,

1 Like

that’s what I needed. Thank you very much.

1 Like

Dim today As Date = Date.Today
Dim firstDayPrevMonth As Date = DateAdd(Month, -1, DateAdd(Day, 1, DateAndTime.EndOfMonth(DateAdd(Month, -2, today))))
Dim lastDayPrevMonth As Date = DateAndTime.EndOfMonth(DateAdd(Month, -1, today))

SQL
DECLARE @today DATE = GETDATE();
SELECT DATEADD(month, -1, DATEADD(day, 1, EOMONTH(@today, -2))) AS FirstDay,
EOMONTH(@today, -1) AS LastDay;