Lasso Soft Inc. > Home


AuthorBil Corry
LicensePublic Domain
Posted02 Dec 2005
Updated02 Dec 2005
More by this author...


Returns the last day of a given month.  May specify the month and year either as a [date] or as -month and -year.  Omitting the month chooses current month.  Omitting the year choose current year.

Note: Requires [lp_date_leapyear]

Sample Usage

lp_date_monthlastday: -month=2, -year=2000;



Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.


	-description='Returns the last day of a given month.',


	// get date
	if: local_defined:'date' && #date->type == 'date';
		#month_selected = #date->month;
		#year_selected = #date->year;
	if: local_defined:'month' && (integer:#month) >= 1 && (integer:#month) <= 12;
		#month_selected = integer:#month;
	if: local_defined:'year' && (integer:#year) >= 1000 && (integer:#year) <= 9999;
		#year_selected = integer:#year;
	select: #month_selected;
		case: 1;
			return: 31;
		case: 2;
			if: (lp_date_leapyear: #year_selected);
				return: 29;
				return: 28;
		case: 3;
			return: 31;
		case: 4;
			return: 30;
		case: 5;
			return: 31;
		case: 6;
			return: 30;
		case: 7;
			return: 31;
		case: 8;
			return: 31;
		case: 9;
			return: 30;
		case: 10;
			return: 31;
		case: 11;
			return: 30;
		case: 12;
			return: 31;
	return: 0; // error


Related Tags


06 Feb 2006, Bil Corry


In order to subtract one second, you would have to extract the month and year from the date passed, add one month (and possibly one year if December) to the date, make sure the time is set to midnight, then subtract some delta (I would recommend something safer than one second, like 12 hours), then extract the ->day and return it.

05 Feb 2006, Richard Moore

Another option

I believe a faster way is typically to get the first of the next month and subtract a second.

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home



©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft