determine nr of days in a month

  • Thread starter Thread starter Linda
  • Start date Start date
L

Linda

Is there an easy way to find out the exact nr of days
there are in the 2 preceding month when for example you
have a date let's say 03/15/2004 and then you want to
count the nr of days of the two preceding months, in this
case JAN and FEB, so that the total becomes 60?

TIA.
 
Pretty Simple:

Function Daycnt()
Dim dte1 As Date, Dte2 As Date
dte1 = DateSerial(Year(Now), Month(Now), 1) - 1 '(Last Day of last month)
Dte2 = DateSerial(Year(dte1), Month(dte1), 1) - 1 '(same for 2 months ago)
Daycnt = Day(dte1) + Day(Dte2)
End Function

HTH
Pieter
 
Is there an easy way to find out the exact nr of days
there are in the 2 preceding month when for example you
have a date let's say 03/15/2004 and then you want to
count the nr of days of the two preceding months, in this
case JAN and FEB, so that the total becomes 60?

TIA.

Yes, with help from a couple of builtin date functions: Let's say this
field is name MyDate.

DateDiff("d", DateSerial(Year([MyDate]), Month([MyDate]) - 2, 1),
DateSerial(Year([MyDate]), Month([MyDate]), 0))

will figure out the first day of two months ago and the last date of
last month and return the difference in days.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top