Formula to calc number of days in a given month (1 Viewer)

FrostByte

Registered User.
Local time
Today, 19:13
Joined
Jan 15, 2015
Messages
56
Im trying do do what I think should be simple i.e. calculate the number of days in a given month but I cannot work it out.

Any help you be appreciated.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 19:13
Joined
Sep 12, 2006
Messages
15,660
the easiest way is to set a date equal to the first of the following month, and subtract one. That gives you the last day of the previous month, and then you can use the DAY() function.
Alternatively, have an array set to {31,28,31,30 etc), although you still get the issue with the leap day that way.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 19:13
Joined
Jul 9, 2003
Messages
16,285
This thread covers a few different ways:-

 

Gasman

Enthusiastic Amateur
Local time
Today, 19:13
Joined
Sep 21, 2011
Messages
14,350
I seem to recall @Pat Hartman uploaded a db with handy date routines? Search for it here.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:13
Joined
Oct 29, 2018
Messages
21,491
How about?
Code:
Day(DateSerial(Year(DateField), Month(DateField)+1, 0))
You didn't say how you're going to supply the month to search, so I just assumed you will use a date value.
Hope that helps...
 

Users who are viewing this thread

Top Bottom