Last Day of Month

Stimulsoft Reports.NET discussion
Post Reply
TimWoods
Posts: 10
Joined: Thu Mar 27, 2014 9:56 pm

Last Day of Month

Post 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?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Last Day of Month

Post 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.
TimWoods
Posts: 10
Joined: Thu Mar 27, 2014 9:56 pm

Re: Last Day of Month

Post by TimWoods »

That worked perfectly. Thank you.
Andrew
Posts: 4104
Joined: Fri Jun 09, 2006 3:58 am

Re: Last Day of Month

Post by Andrew »

Hello, Tim.

It is a pleasure to help you.

Thank you.
KP493
Posts: 1
Joined: Fri Nov 12, 2021 2:13 pm

Re: Last Day of Month

Post 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?
Last edited by KP493 on Fri Nov 12, 2021 2:24 pm, edited 2 times in total.
Lech Kulikowski
Posts: 6197
Joined: Tue Mar 20, 2018 5:34 am

Re: Last Day of Month

Post 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))}
Post Reply