Page 1 of 1

Last Day of Month

Posted: Tue Nov 04, 2014 3:18 pm
by TimWoods
I have a variable called AsOfDate that contains a date (such as 10/15/2014). How do I find the last day of the month of that date, so I can display 10/31/2014 in the report, even though the date in the variable is 10/15/2014?

Re: Last Day of Month

Posted: Wed Nov 05, 2014 6:40 am
by Alex K.
Hello,

Please try to use the following expression:

Code: Select all

{new DateTime(AsOfDate.Year, AsOfDate.Month, DateTime.DaysInMonth(AsOfDate.Year, AsOfDate.Month))}
Thank you.

Re: Last Day of Month

Posted: Thu Nov 06, 2014 7:21 pm
by TimWoods
That worked perfectly. Thank you.

Re: Last Day of Month

Posted: Fri Nov 07, 2014 5:56 am
by Andrew
Hello, Tim.

It is a pleasure to help you.

Thank you.

Re: Last Day of Month

Posted: Fri Nov 12, 2021 2:16 pm
by KP493
Hi,
I have a field called (report___remittance_report.Date___Due_Date) that contains certain dates in a month.
How can I get the First and Last Dates of the month?

Re: Last Day of Month

Posted: Mon Nov 15, 2021 11:10 pm
by Lech Kulikowski
Hello,

You can use following expressions:
first - {new DateTime(report___remittance_report.Date___Due_Date.Year, report___remittance_report.Date___Due_Date.Month, 1)}
last - {new DateTime(report___remittance_report.Date___Due_Date.Year, report___remittance_report.Date___Due_Date.Month, DateTime.DaysInMonth(report___remittance_report.Date___Due_Date.Year, report___remittance_report.Date___Due_Date.Month))}