Get last day of last month as "dd.MM.yyyy"

Hello everybody,

I am trying to get the last day of last month as the following string “dd.MM.yyyy” to use it as date filter in excel.
Example: today is 02.06.2020 → I need to get 31.05.2020.

I already tried with the function “daysinmonth”, but unfortunately it didn’t work.

Does anybody have an idea how to do this?
Thank you!

1 Like

If MyDate is your Date or Datetime datatype variable, you can get the last day in the current month by assigning another Date or Datetime variable to MyDate.AddDays(MyDate.DaysInMonth - MyDate.Day).

In case of you are not bound to the daysInMonth approach. For another Technique have a look below:


Great, thanks!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.