Default as days in month

  • Thread starter Thread starter dimpie
  • Start date Start date
D

dimpie

I want to assign total number of days in the current month to a text field.
Please let me know if there is a function that does that.

Thank you!
 
dimpie said:
I want to assign total number of days in the current month to a text
field. Please let me know if there is a function that does that.

Thank you!

Format(DateSerial(Year(Date()), Month(Date()) + 1, 0), "d")
 
Rick Brandt said:
Format(DateSerial(Year(Date()), Month(Date()) + 1, 0), "d")

Or Day(DateSerial(Year(Date()), Month(Date()) + 1, 0), "d") or DatePart("d",
DateSerial(Year(Date()), Month(Date()) + 1, 0))

I prefer either of these to using Format, since Format returns a string, and
there requires coercion back to an integer, where as the Day and DatePart
functions return a number.
 
Douglas said:
Or Day(DateSerial(Year(Date()), Month(Date()) + 1, 0), "d") or
DatePart("d", DateSerial(Year(Date()), Month(Date()) + 1, 0))

I prefer either of these to using Format, since Format returns a
string, and there requires coercion back to an integer, where as the
Day and DatePart functions return a number.

Good point and one which I had considered until I saw that the OP specified
that he wants the value to go into a "text field". In most cases though you
are correct that a numeric value would be the most likely result desired.
 
Back
Top