Brian Dunning's FileMaker Custom Functions

DaysInMonth ( text )

Calculates the number of days in a chosen month

  Average rating: 4.5 (11 votes) Log in to vote

Neil Manchester   Neil Manchester - Show more from this author
NDMW

Share on Facebook Share on Twitter

  Sample input:
DaysInMonth ( 16/02/2016 )
  Sample output:
29

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

This is a simple CF that returns the number of days in a given month taking into account leap years.

 

Comments

comment   comment, VR
Aug 21, 2016
First, your calculation of leap years is incorrect. You will get a wrong result for the month of February 2100, for example.


Next, you should not prefix your variables with $, because these hang around until the end of the session - and they might interfere when the function is called again.


Finally, the number of days in a given month can be calculated much more simply as:

Day ( Date ( Month ( GivenDate ) + 1 ; 0 ; Year ( GivenDate ) ) )
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: