Jump to content

Last day of the month (28,29,30 or31)?


Recommended Posts

Months with 31 days are: 1, 3, 5, 7, 8, 10, 12

Months with 30 days are: 4, 6, 9, 11

If month == 2, then: 

if (year % 4 == 0)
{
	if (year % 100 == 0 && year % 400 != 0)
	{
		daysInMonth = 28;
	}
	else
		daysInMonth = 29;
}
else
	daysInMonth = 28;

 

That's what I remember...

Link to comment
Share on other sites

  • 1 month later...

I had a similar "problem"

I made a calendar as a indexed table, with 366 days (so it's always a leap year)

to know the index of the current day, I take the day of the month and add a fixed value corresponding the actual month.....

so if we are may 2, then I add 91 minus 1 and my index in my data table is 92....

used a switch case....

image.png.cab071419a6fc3b894c63660b67bc816.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...