By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,252 Members | 1,670 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,252 IT Pros & Developers. It's quick & easy.

How to get days from a Combo Box?

P: 36
Hi there!
I have a combo box namely "Statement for". In this combo box all months are entered. When I will select any month in Combo box "Working days" automatically generated. I can use If function, but then what about leap year? After 4 years leap year will come and 29 February will be effected in my database. Any suggestion? Thanks in advance.
Attached Images
File Type: jpg untitled.jpg (47.4 KB, 74 views)
Feb 19 '15 #1
Share this Question
Share on Google+
1 Reply


jforbes
Expert 100+
P: 1,107
Here is a function you can use:
Expand|Select|Wrap|Line Numbers
  1. Public Function getDaysInMonth(ByRef dDate As Date) As Integer
  2.     getDaysInMonth = DateDiff("d", dDate, DateAdd("m", 1, dDate))
  3. End Function
You get results like this:
Expand|Select|Wrap|Line Numbers
  1. ?getDaysInMonth(dateserial(2016, 2,1))
  2.  29 
  3. ?getDaysInMonth(dateserial(2015, 2,1))
  4.  28 
  5. ?getDaysInMonth(dateserial(2015, 2,29))
  6.  31 
Feb 19 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.