![]() |
PROJECT PERFECT Project Management Software Specialists in Project Infrastructure |
|
|
Home - Microsoft Access Development - Microsoft Access Tips Sample Microsoft Access VBACalculating the number of days in a monthThe following are some samples of VBA code that may prove useful. This is a simple function that allows you to find the number of days in a month. Pass the date to the function and it will return the number of days. Leap years are accounted for. Assume you have a variable called intDaysInMonth and a date called dteMyDate. To call the function use this: intDaysInMonth = funDaysInMonth(dteMyDate) if dteMyDate were 8 Jan 2009, intDaysInMonth would be 31. One point is worth noting. Since the Mid function starts counting from one, you need to start the string with a number that will never be returned. It can be anything but we have used 0. For January which is month 1, we start counting from 2 ( Month(dteDate) * 2). 2 is the second character. We need to put a filler in position one.
|
|---|