How can we get the last day of the month?

Hi,

I need to get the last day in a month. E.g October month last day is “Tuesday”
By the way needs to get the last day in a month. Can anyone guide me please.
Thanks in Advance,
Ashnitha T

@jamunatj

Try this

DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)

OR

lastDayOfMonth As DateTime = Enumerable.Range(1, DateTime.DaysInMonth(year, month)) _
.Select(Function(day) New DateTime(year, month, day)) _
.LastOrDefault(Function(date) date.DayOfWeek = DayOfWeek.Tuesday)

With Activity:
grafik

1 Like

Hi @jamunatj

How about this expression?

You can try this expression in the Assign activity

(New DateTime(Today.AddMonths(1).Year,Today.AddMonths(1).Month,1)).AddDays(-1).toString("dddd")

image

Hello @jamunatj
Try this

DateSerial(now.Year,now.AddMonths(1).Month,0).ToString("dd") ------> 31
DateSerial(now.Year,now.AddMonths(1).Month,0).DayOfWeek  -----> tuesday
DateSerial(now.Year,now.AddMonths(1).Month,0).Tostring("dd-MM-yyyy") ---->31-10-2023

image

Hi @jamunatj

CurrentDate=DateTime.Now                     DataType:System.DateTime
LastDayofMonth=New DateTime(CurrentDate.Year, CurrentDate.Month, 1).AddMonths(1).AddDays(-1).DayOfWeek                      DataType:System.DayOfWeek

Hope this helps!!

Hi @jamunatj

str_lastedate= New DateTime(now.Year, now.Month, DateTime.DaysInMonth(now.Year, now.Month)).ToString
str_Date= CDate(str_lastedate).DayOfWeek

Print str_Date in Message Box

Note: str_lastdate is of DataType System.String. str_Date is of DataType System.DayOfWeek.

Hope it helps!!

Hi

lastDayOfMonth = New DateTime(Now.Year, Now.Month, 1).AddMonths(1).AddDays(-1)

Thank you

Hi,

You can use below expression

DateTime.DaysInMonth(Year(Today), Month(Today)).ToString(“dddd”)

  1. DateTime.DaysInMonth(Year(Today), Month(Today)): This part calculates the number of days in the current month. Year(Today) gives the current year, and Month(Today) gives the current month. So, it finds how many days are in the current month.

  2. .ToString("dddd"): After finding the number of days in the month, this part converts it to a full day name. The format specifier “dddd” is used to get the full day name (e.g., “Tuesday”).