Days in part of the month

L

Leo

If I have a date ('VisitDate')then if I need to know how many days in that
particular month from that given date, the following VBA code helps:

Day(DateSerial(Year([VisitDate]), Month([VisitDate]) + 1, 0))

If I need to calculate the number of days in that month before the visit
date, how will I write a straight forward VBA code like the one above?

Could someone please help?

Thanking you in advance
Leo
 
F

fredg

If I have a date ('VisitDate')then if I need to know how many days in that
particular month from that given date, the following VBA code helps:

Day(DateSerial(Year([VisitDate]), Month([VisitDate]) + 1, 0))

If I need to calculate the number of days in that month before the visit
date, how will I write a straight forward VBA code like the one above?

Could someone please help?

Thanking you in advance
Leo

I'm not sure I understand your question.
If you wish to know how many days from the beginning of the month to
the [VisitDate] all you need do is use
= Day([VisitDate])
So March 20 returns a 20.
If you wish to know how many days from a date to the end of the that
dates month, use:

= DateSerial(Year([VisitDate]), Month([VisitDate]) + 1, 0) -
[VisitDate]

For March 20, 2010 it will return 11
 

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

Top