D J Horton Consulting Ltd

Personal reference to useful tips and tricks for SQL Server, SQL Server Reporting Services and Crystal Reports.

My alternative to scraps of paper lying about.

Friday, 30 October 2009

Get last day of month - CR

local numbervar thismonth := Month(CurrentDate)+1;
local numbervar thisyear := Year(CurrentDate);
local datevar endday;

endday := Date(thisyear, thismonth, 1)-1; //get the last day of the month


Anonymous said...

thank worked perfect for what I needed.

Dom Horton said...

no worries!

Anonymous said...

its for vb.net?

Dom Horton said...

It's for Crystal Reports. Very similar for VB though:

Local thismonth As Number
Local thisyear As Number

thismonth = Month(CurrentDate)+1
thisyear = Year(CurrentDate)

formula = cDate(thisyear, thismonth, 1)-1